Trouble Passsing Data

R

rodnice

I know I was able to do it once before on a db project
but can't remember now.

I have a form with a button on it. I want the ID value
of the record that the button pertains to, to let the
query/form know to only display the values that belong
to that record.

This form is a subform already. So.. how would I pass
the data?
 
A

Albert D. Kallal

If you are talking about a button on the same detail line (in the sub-form),
then you can use the following line of code:

me.refresh (you need this line of code if you allow editing)
docmd.OpenForm "the form",,,"id = " & me.id

The above assumes a key id field of "id",.....if your key id is
different..then change it.

And, for some screen shots of forms/sub-forms, and what I mean by place a
"button"on the form...check out:

http://www.attcanada.net/~kallal.msn/Articles/Grid.htm
 
R

rodnice

Thanks for the help, and the link to your site.

My problem now is that I wanted the criteria for
two fields to produce the results.

I want the ID and the Serial field to be the criteria
of the generated report when the button is clicked.
Now what
 
R

rodnice

Thanks for the help, and the link to your site.

My problem now is that I wanted the criteria for
two fields to produce the results.

I want the ID and the Serial field to be the criteria
of the generated report when the button is clicked.
Now what
 
A

Albert D. Kallal

Sure, assuming a button, we can use:


dim strWhere as string

strWhere = "(id = " & me.ID & ") and " & _
"(SerialNum = " & me.Serial & ")"

docmd.OpenForm "theForm",,,strWhere

So, you can add, or have as many conditions you want with that where clause.

If the serial number is a text, and NOT number, then you have to use all the
standard sql syntax..and that means you must surround the serialNumber with
quotes. So, the above would become:


strWhere = "(id = " & me.ID & ") and " & _
"(SerialNum = '" & me.Serial & "')"

docmd.OpenForm "theForm",,,strWhere

I used single quotes...and it should work just fine.
 

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