Macro to synchronize records in 2 forms with where cond. action ar

H

headly

i put a command button on my customer form. in the on click event i run a
macro (macro1) to open the contact form. Why can't I use a where condition to
set [Forms]![Customer Form]![CustomerID]=[Forms]![Contact Form]![Customer ID]
 
T

tina

well, give it a try. and if you're opening the Contact form from the
Customer form, then try changing your WHERE clause to

[Forms]![Contact Form]![CustomerID] = [Forms]![Customer Form]![CustomerID]

or just

[CustomerID] = [Forms]![Customer Form]![CustomerID]

hth


headly said:
i put a command button on my customer form. in the on click event i run a
macro (macro1) to open the contact form. Why can't I use a where condition to
set [Forms]![Customer Form]![CustomerID]=[Forms]![Contact Form]![Customer
ID]
 
T

tina

well, as to *why*, i couldn't say - i've never had much luck with the WHERE
clause argument in a macro. suggest you use VBA code instead, as

DoCmd.OpenForm "FormName", , , _
"FieldName = " & Me!FieldName

replace FormName with the name of the form you want to open; replace the
first FieldName with the name of the field in the form being opened; replace
the second FieldName with the name of the control in the form that the code
is running in.
if the field is Text data type rather than Number data type, change the
syntax to

DoCmd.OpenForm "FormName", , , _
"FieldName = '" & Me!FieldName & "'"

read up on the OpenForm Action in VBA Help so you'll understand how to use
the arguments. if you don't know how to create an event procedure in a form,
go to http://home.att.net/~california.db/instructions.html and click on the
CreateEventProcedure link for illustrated instructions in PDF format.

also, recommend that you remove the spaces in your form names. for more
information, see http://home.att.net/~california.db/tips.html#aTip5.

hth


headly said:
Yeah, that's what I have and it doesn't work, although it's supposed to. Why
would it be not working when it should? (I get 0/0 records filtered as a
result).

tina said:
well, give it a try. and if you're opening the Contact form from the
Customer form, then try changing your WHERE clause to

[Forms]![Contact Form]![CustomerID] = [Forms]![Customer Form]![CustomerID]

or just

[CustomerID] = [Forms]![Customer Form]![CustomerID]

hth


headly said:
i put a command button on my customer form. in the on click event i run a
macro (macro1) to open the contact form. Why can't I use a where
condition
to
set [Forms]![Customer Form]![CustomerID]=[Forms]![Contact
Form]![Customer
ID]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top