Open Form command based on a number

C

cbayardo

I want to open a form from another form with a Command button, but I want the
record on the form that I open to be a specific record based on the first
form. For example: FormX has a field called Dog. FormY also has that same
field Dog. When I click the command button if Dog is equal to 10 on FormX,
the FormY should open on the record Dog=10. I have this is the Command
button...OnClick...
DoCmd.OpenForm,,,FormY.Dog=FormX.Dog, but this does not work, I even tried
FormY=10 and it does not work. Any ideas?
Thanks
 
F

fredg

I want to open a form from another form with a Command button, but I want the
record on the form that I open to be a specific record based on the first
form. For example: FormX has a field called Dog. FormY also has that same
field Dog. When I click the command button if Dog is equal to 10 on FormX,
the FormY should open on the record Dog=10. I have this is the Command
button...OnClick...
DoCmd.OpenForm,,,FormY.Dog=FormX.Dog, but this does not work, I even tried
FormY=10 and it does not work. Any ideas?
Thanks


Where did you come up with this syntax from?
It's helpful to read VBA Help.

DoCmd.OpenForm "FormY", , , "Dog] = " & Me![Dog]

The above assumes the Datatype of [Dog] is a Number datatype.

If it is Text datatype, then use
"[Dog] = '" & Me![Dog] & "'"
 
C

cbayardo

Thanks, Fred. That works great.

fredg said:
I want to open a form from another form with a Command button, but I want the
record on the form that I open to be a specific record based on the first
form. For example: FormX has a field called Dog. FormY also has that same
field Dog. When I click the command button if Dog is equal to 10 on FormX,
the FormY should open on the record Dog=10. I have this is the Command
button...OnClick...
DoCmd.OpenForm,,,FormY.Dog=FormX.Dog, but this does not work, I even tried
FormY=10 and it does not work. Any ideas?
Thanks


Where did you come up with this syntax from?
It's helpful to read VBA Help.

DoCmd.OpenForm "FormY", , , "Dog] = " & Me![Dog]

The above assumes the Datatype of [Dog] is a Number datatype.

If it is Text datatype, then use
"[Dog] = '" & Me![Dog] & "'"
 

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