Sunday 15 January 2012

ms access - Multiple Fields In Query Statement -


Then the following query statement works fine. But I need to add an extra area to check, is it possible?

So if FIELD1 or FIELD2 is in combo254.text, then select those records.

> Here's the current query I'm running: Temp = Combo254.Text Dim strSQL string strrowhere as string strWhere = (Chr (34) + Combo254 .Text + (Chr (34)) StrSQL = "SELECT * FROM MainQuery WHERE [FIELD1]" Like & amp; StrWhere 'MsgBox (strSQL) [Form_Main] .RecordSource = strSQL

Connect with each Additional criteria with the term and or OR .

As a side note, VBA allows you to double quotation marks to include quotation marks in literal strings. I think this is slightly more readable than using Chr (34).

  strSQL = "Select + From the main menu" & amp; _ "Where" [FIELD1] like "&" Combo 254 Text & amp; "" "Or" & amp; _ "[FIELD2] such as" "" & amp; Combo 254 Text & amp; In this situation, access is ignored so that you use single quotes or double quotes, so that you can rewrite the query in this way. :  
  strSQL = "SELECT * FROM Mainclin" & amp; _ "" Like & [FIELD1] like "& amp; combo 254. Text & amp;" 'or' & amp; _ "Like" [FIELD2] "& amp; combo 254. Text & amp;" '"   

No comments:

Post a Comment