Issue with SQL code in Microsoft Access

时间:2018-02-01 18:11:57

标签: sql database ms-access

I have a button in my database that is supposed to find a record when it is clicked. The issue I am encountering is that I want it to search for a record based on two fields.

This is my code:

I am using the SearchForRecord macro with Where Condition

="[Short Title] = " & "'" & [Combo101] & "'" And "[Baseline] = " & "'" & [Combo103] & "'"

It is not liking this. If I just have the Where condition as

="[Short Title] = " & "'" & [Combo101] & "'" 

or I have it as

="[Baseline] = " & "'" & [Combo103] & "'" 

then it works fine. But when I try to combine the two (which I need to do) it will not find any records.

I tried to break it up into two separate SearchForRecord macros and while that did return records when I clicked the button, it still wasn't working properly.

It would be ideal if someone could let me know why my original code was not working and what needs to be done to fix it.

1 个答案:

答案 0 :(得分:1)

Try:

="[Short Title] = '" & [Combo101] & "' AND [Baseline] = '" & [Combo103] & "'"
相关问题