Open Form Where Condition

R

Ripper

I am attempting to open a form from a continuous form using the Where
Condition.

DoCmd.OpenForm "frmNonCountablesEdit", acNormal, , TestID = Me.TestID And
BoxNumber = Me.BoxNumber

The form opens and shows all the records instead of filtering the results to
the TEstID and BoxNum. Both the TestID and BoxNumber are numbers. I guess I
need a tutorial in Where Conditioning. Can anyone help?
 
D

Daniel Pineault

Try something like:

Dim sWhere as string

sWhere = "[TestID]=" & Me.TestID & " AND [BoxNumber]=" & Me.BoxNumber

DoCmd.OpenForm "frmNonCountablesEdit", acNormal, , sWhere
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
F

fredg

I am attempting to open a form from a continuous form using the Where
Condition.

DoCmd.OpenForm "frmNonCountablesEdit", acNormal, , TestID = Me.TestID And
BoxNumber = Me.BoxNumber

The form opens and shows all the records instead of filtering the results to
the TEstID and BoxNum. Both the TestID and BoxNumber are numbers. I guess I
need a tutorial in Where Conditioning. Can anyone help?

The Where argument must be a string (enclosed within quotes) and the
criteria values must be concatenated into the string.
"TestID = " & Me.TestID & " And BoxNumber = " & Me.BoxNumber

The above assumes both fields are a Number datatype.
If Boxnumber, for example, is a text datatype, then you would use:

"TestID = " & Me.TestID & " And BoxNumber = '" & Me.BoxNumber &"'"
 

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