Open Form Where Condition

  • Thread starter Thread starter Ripper
  • Start date Start date
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?
 
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.
 
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 &"'"
 
Back
Top