jmt137
07-20-2009, 04:09 PM
Ok, I'm a noob at creating macros but I have a data base that i need to copy info from one form, open and paste it into another. Fields i want to copy over are listed below. I was wondering if someone could help me to create a macros to do it with using the Button (form control) in form design view?
form to copy from: Contact Details
Form to paste into: Invoice Details
Fields to copy:
Customer ID
First Name
Last Name
Phone Number
Email
Address
and when this button is pressed in the Contact Details form to automatically open the Invoice Details form and input the the data in those fields.
Any help would be greatly appreciated.
JT
pbaldy
07-20-2009, 04:56 PM
Personally I would use VBA code, which would look like:
Forms!TargetForm.ControlName = Me.ControlName
If you want to stay with a macro, you'd want the SetValue action.
Mike375
07-20-2009, 05:27 PM
With SetValue the left of the = sign in Paul's example is Item and the right of the = sign is Expression but you use full reference
[Forms]![TargetForm]![ControlName] for both item and expression.
I use macros a real lot but if you are seeking solutions from the forum you are best to learn at least the basics of VBA, especially where to put it as 99.9999999% of the answers will be given in VBA
jmt137
07-22-2009, 06:24 AM
OK so i found the setvalue action, now when i click the button it opens the invoice details but gives this error message:
Macro Name:
Contact Details : Command277 : OnClick : Embedded Macro
Condition:
True
Action Name:
SetValue
Arguments:
[Forms]![Contact Details]![Last Name], [Forms]![Invoice Details]![Last Name]
it comes up with error number 2950. When in the Macro page i get a yellow triangle around an exclamation point next to the line. I have the trust center set to enable macros. Any Help again would be much appreciated.
jt
jmt137
07-22-2009, 10:39 AM
Ok I did find that i had an error in that database setup and made a new one, Then found i had the Contact details and Invoice Details switched so it was deleting the info from the contact details form. Swapped those and now works great.