By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,642 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,642 IT Pros & Developers. It's quick & easy.

record set base on two criteria

100+
P: 222
Hello Everybody

I'm using this code to set a record set with 1 criteria .. It is working

Dim mysql As String
mysql = "SELECT * FROM [Invoiceoutdetail]" _
& "WHERE([customerID])= " & [custID] & ""

Set db = CurrentDb()
Set rst = db.OpenRecordset(mysql, dbOpenDynaset)

what I'm trying to do is to replace mysql by this code to use 2 criterias ..
Dim mysql As String
mysql = "SELECT * FROM [Invoiceoutdetail]" _
& "WHERE([customerID])= " & [custID] & ""_
& And "[Barecodedetail]='" & [Barecodedetail] & "')"

I always have an error ...

Does someone Know How we can use double criterias for a record set ?
Jun 3 '07 #1
Share this Question
Share on Google+
3 Replies

theaybaras
P: 52
Try declaring a separate sql string:

Expand|Select|Wrap|Line Numbers
  1. Dim SQLStr as string
  2. SQLStr = "Select * from tblInvoiceoutdetail & WHERE customerID = " & custID 
  3. SQLStr = SQLStr & " AND Barecodedetail = " & Barecodedetail
  4.  
  5. .. And if MySQL then
  6. SQLStr = SQLStr & ";"
  7. then
  8. SetRS = CurrentDb.Openrecordset (SQLStr)
  9.  
  10.  
if this doesn't work... I'm not sure how to proceed... took me awhile to find this solution.

theAybaras
Jun 3 '07 #2

JConsulting
Expert 100+
P: 603
Hello Everybody

I'm using this code to set a record set with 1 criteria .. It is working

Dim mysql As String
mysql = "SELECT * FROM [Invoiceoutdetail]" _
& "WHERE([customerID])= " & [custID] & ""

Set db = CurrentDb()
Set rst = db.OpenRecordset(mysql, dbOpenDynaset)

what I'm trying to do is to replace mysql by this code to use 2 criterias ..
Dim mysql As String
mysql = "SELECT * FROM [Invoiceoutdetail]" _
& "WHERE([customerID])= " & [custID] & ""_
& And "[Barecodedetail]='" & [Barecodedetail] & "')"

I always have an error ...

Does someone Know How we can use double criterias for a record set ?
Dim mysql As String
mysql = "SELECT * FROM [Invoiceoutdetail] WHERE" & _
" [customerID]= " & me.[custID] & " And '" [Barecodedetail]='" & me.[Barecodedetail] & "';"
Jun 3 '07 #3

100+
P: 222
Both worked ThanK you ...
Jun 3 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.