Macros "Where Condition" not working properly

S

Silvio

Hello, I have a macro that open and filter a form based on two conditions:
CustomerID and ProgramID. However, it does not filter as intended. I most
likely I am missing something when concatenating the two conditions, any idea?

="[Customer_ID]=" & [CustomerID] And "[Program_ID]=" & [ProgramID]


P.S. CustomerID and ProgramID are both numeric.

Thank you,
Silvio
 
D

DrGUI

Place an ampersand and the double quote before the ' And'. See below:


= "[Customer_ID]=" & [CustomerID] & " And [Program_ID]=" & [ProgramID]
 
M

Mike Painter

Silvio said:
Hello, I have a macro that open and filter a form based on two
conditions: CustomerID and ProgramID. However, it does not filter as
intended. I most likely I am missing something when concatenating the
two conditions, any idea?

="[Customer_ID]=" & [CustomerID] And "[Program_ID]=" & [ProgramID]
="[Customer_ID]=" & [CustomerID] & " And [Program_ID]=" & [ProgramID]
 
S

Silvio

Thank you folks, this is working great! I hope one day to fully understand
the quotation mark logic :)

Mike Painter said:
Silvio said:
Hello, I have a macro that open and filter a form based on two
conditions: CustomerID and ProgramID. However, it does not filter as
intended. I most likely I am missing something when concatenating the
two conditions, any idea?

="[Customer_ID]=" & [CustomerID] And "[Program_ID]=" & [ProgramID]
="[Customer_ID]=" & [CustomerID] & " And [Program_ID]=" & [ProgramID]


.
 
M

Mike Painter

Silvio said:
Thank you folks, this is working great! I hope one day to fully
understand the quotation mark logic :)

Mike Painter said:
Silvio said:
Hello, I have a macro that open and filter a form based on two
conditions: CustomerID and ProgramID. However, it does not filter as
intended. I most likely I am missing something when concatenating
the two conditions, any idea?

="[Customer_ID]=" & [CustomerID] And "[Program_ID]=" & [ProgramID]
="[Customer_ID]=" & [CustomerID] & " And [Program_ID]=" &
[ProgramID]
If I have a line like that in a code block I will usually pop it up in a
msgbox to see if it looks right.
 

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