Open Form Where Statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using a DoCmd.Openform statement:

DoCmd.OpenForm "frmE_BOM, , "[BOM Number]=" & "'" & Me![BOM Number] & "'", ,
acWindowNormal

I want to insert a second field [BOM Revision] (same field name on both
forms) for filtering but don't seem to get the And statement correct.

Bernie
 
Bernie,

Your syntax implies the BOM number is text rather than numeric. Is this
correct?
Assuming both the BOM number and revision are text, try something like:

Dim strWhere As String
strWhere = "[BOM Number]='" & Me![BOM Number] & "' And " _
& "[BOM Revision]='" & Me![BOM Revision] & "'"
DoCmd.OpenForm "frmE_BOM", , , strWhere, , acWindowNormal

Make sure you don't miss any of the spaces in the strWhere expression,
they are important!
In case the two are indeed numeric:

Dim strWhere As String
strWhere = "[BOM Number]=" & Me![BOM Number] & " And " _
& "[BOM Revision]=" & Me![BOM Revision]
DoCmd.OpenForm "frmE_BOM", , , strWhere, , acWindowNormal

(dropped the single quotes around the textbox references).

HTH,
Nikos
 
try

DoCmd.OpenForm "frmE_BOM, , "[BOM Number] = '" & Me![BOM Number] & "' And
[BOM Revision] = '" & Me![BOM Revision] & "'", , acWindowNormal

the above assumes that both the [BOM Number] and [BOM Revision] fields are
Text data type.

hth
 
Just use the AND operator

"[BOM Number] = 1204 AND [BOB Revision] = 4" from there its just
changing the string to accomodate values obtained from form controls.
 
Back
Top