Macros "Where Condition" not working properly

  • Thread starter Thread starter Silvio
  • Start date Start date
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
 
Place an ampersand and the double quote before the ' And'. See below:


= "[Customer_ID]=" & [CustomerID] & " And [Program_ID]=" & [ProgramID]
 
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]
 
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]


.
 
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.
 
Back
Top