Changing form values from a macro

barboza

Registered User.
Local time
Yesterday, 19:33
Joined
Aug 22, 2007
Messages
23
I have written the following macro that is in module 1.

Sub Test()
DoCmd.SelectObject acForm, "frmCustody"
frmCustody.Me.Controls("F9").Value = "Ag"
End Sub

I get the following error: Object required.
Any ideas how to get the value to show up in the form when the macro runs??

Thanks,
B
 
I have written the following macro that is in module 1.

Sub Test()
DoCmd.SelectObject acForm, "frmCustody"
frmCustody.Me.Controls("F9").Value = "Ag"
End Sub

I get the following error: Object required.
Any ideas how to get the value to show up in the form when the macro runs??

Thanks,
B

The correct syntax is:
Code:
Forms!frmCustody!F9 = "Ag"
OR
Code:
Forms!frmCustody.F9="Ag"
OR
Code:
Forms("frmCustody").Controls("F9").Value = "Ag"

The first two don't need .Value specified, but the third does and all three will accomplish the same thing.
 
Many Thanks

Thanks Bob.

Once again, you are right on the money!
 

Users who are viewing this thread

Back
Top Bottom