Others

How to Copy a Text Box Value Using an Access Command Button

Rana GarciaRana Garcia Nov 2, 2026 871 views

Question details

The user needs a method to duplicate data from one text box to another within a form using an Access command button.

How to Copy a Text Box Value Using an Access Command Button
Product
Microsoft Access
Device & OS
not provided
Scenario
Designing a database form where clicking a button automatically copies a value between specific text boxes.
Observed behavior
The user is looking for the correct macro action (such as SetValue) or VBA method to transfer the value seamlessly without utilizing the system clipboard.
Before you start

Ensure your Access form is open in Design View and that both the source and destination text boxes have identifiable names (e.g., txtSource and txtDestination).

Solution 1Recommended

Use the SetValue Macro Action

The simplest way to copy a value without relying on the system clipboard is to assign the SetValue macro within the button's On Click event.

This method updates the destination text box instantly when the button is pressed. It bypasses the system clipboard, making it more robust than typical copy-paste commands like acCmdCopy.

1
Open form in Design View

Right-click your form in the navigation pane and select 'Design View'.

2
Access the button properties

Select the command button, press F4 to open the Property Sheet, and click on the 'Event' tab.

3
Open the Macro Builder

Click the ellipsis (...) next to the 'On Click' property and choose 'Macro Builder'.

4
Add the SetValue action

From the 'Add New Action' dropdown, select 'SetValue'. If it does not appear, click 'Show All Actions' in the ribbon first.

5
Configure Item and Expression

In the 'Item' box, enter the name of your destination text box (e.g., [DestinationBoxName]). In the 'Expression' box, enter the name of the source text box (e.g., [SourceBoxName]). Save and close the macro.

No Clipboard Required: Unlike the DoCmd.RunCommand acCmdCopy method, SetValue copies the data quietly in the background without affecting your clipboard history.
Free Microsoft Office alternative

Looking for a Powerful, Lightweight Office Suite?

While WPS Office does not feature a dedicated relational database app like Microsoft Access, it provides a powerful spreadsheet tool that fulfills many data entry, validation, and macro-driven data tracking needs. As a complete Office alternative, it ensures you stay productive without heavy subscriptions.

  1. 1. Download the software: Visit the official WPS Office website and download the installation package suited for your operating system.
  2. 2. Install the suite: Run the installer and follow the quick on-screen instructions to set up the software.
  3. 3. Manage your data: Open WPS Spreadsheets to easily manage tabular data, set up advanced data validation, and use built-in formulas for your tracking needs.
Fully compatible with Microsoft Excel (.xlsx), Word (.docx), and PowerPoint (.pptx) formats.Flexible spreadsheet data management serving as a lightweight alternative to complex databases.Free to download with low system resource requirements.Familiar user interface ensuring zero learning curve and seamless migration.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the SetValue macro action not appear in the Macro Builder?

In newer versions of Access, SetValue is considered an 'unsafe' action unless the database is stored in a Trusted Location. To view it, you must click the 'Show All Actions' button in the Macro Builder ribbon.

Can I use DoCmd.RunCommand acCmdCopy to copy the text box?

While it is possible, DoCmd.RunCommand acCmdCopy simulates a user pressing Ctrl+C. It requires you to set focus to the source text box first and relies on the system clipboard, making it much less reliable than the SetValue macro or direct VBA assignment.

Does copying the value automatically save the record in the database?

No, updating the text box via SetValue or VBA only modifies the control locally on the form. The underlying database record is updated only when you save the record manually or navigate to a different row in the form.