• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1329
  • Last Modified:

MS Access 2003 - VBA code to copy 1 field to another in the same form

Dear Experts
I have a form named address.  The form contains fields named:
Business address
Invoice Address

I want to add a button to the form that will copy the details in business address to invoice address.

The actual form is slightly more complicated but if I can understand the above then I will be able to adapt and apply it.

Can someone please help with the VBA?

Thank you.
0
kevin1478
Asked:
kevin1478
  • 2
  • 2
  • 2
2 Solutions
 
TextReportCommented:
If they are both on the same form then in your Button's On Click event procedure you can

Me!InvoiceAddress = Me!txtBusinessAddress

Cheers, Andrew
0
 
kevin1478Author Commented:
Thank you.

Ive implemented the code as suggested and I get the error:

The expression On Click you entered as the event property setting produced the following error: A problem occurred while Microsoft Office Access was communication with the OLE server or ActiveX Control.

To test the error I added a button using the wizard to close the form and I got the same error.

Any ideas please.
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
try:

Me!InvoiceAddress.setfocus
Me!InvoiceAddress = Me!txtBusinessAddress

Assuming this code is running from the same form as the one with these two text boxes on them.

Mike
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Mike EghtebasDatabase and Application DeveloperCommented:
correction...

Assuming this code is running from the same form as the one with these two text boxes on it.
0
 
TextReportCommented:
You must ensure you get the names of the controls correct. Looking at what you said in the first posting it could be

Me![Invoice Address] = Me![Business Address]

Cheers, Andrew
0
 
kevin1478Author Commented:
Thank you. All working.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now