REPOST: Opening a subsequent form from another with filtered crite

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

Guest

Hello,

The answer to this question is probably posted here, but I can't seem to
find the solution. I have a main form/subform on which I have a button that
opens a subsequent form. I need the subsequent form to open with just the
records that are based on a field in the main form AND also a field in the
subform. I can get it to work with one criteria, but not two. I probably
have incorrect syntax or something.

I tried using the where conditon, and I also tried using a filter
referencing those 2 fields. I'm just stuck.

Any suggestions?
Thanks,
D. Collins
 
Perhaps you could post some of the code that "doesn't work", and also say
what it's doing that it shouldn't, or what it isn't doing that it should.
If you're getting any errors, post them, too.
 
Here's the snippet of code:

Dim stDocName As String
Dim strWhere As String
strWhere = "intVendor = " & Me.intVendorID And
"intServiceReferenceNumber = " & Me.intServiceReferenceNumber
stDocName = "frmInvoices"
DoCmd.OpenForm stDocName, , , strWhere

Hope this helps.
 
You have the 'And' as an operator when it needs to be part of the quoted string:

strWhere = "intVendor = " & Me.intVendorID & " And intServiceReferenceNumber =
" & Me.intServiceReferenceNumber

When you get oddities like this it is worth using a MsgBox or a Debug.Print to
show you what you have built in your variable. What has gone wrong is usually
much more obvious then!

HTH
John
 
Thanks John!


John Smith said:
You have the 'And' as an operator when it needs to be part of the quoted string:

strWhere = "intVendor = " & Me.intVendorID & " And intServiceReferenceNumber =
" & Me.intServiceReferenceNumber

When you get oddities like this it is worth using a MsgBox or a Debug.Print to
show you what you have built in your variable. What has gone wrong is usually
much more obvious then!

HTH
John
 
Back
Top