Full Version: Recordsource problems
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
warneri
Hi,

I am attempting to use the following code:

Set recSource = CurrentDb().OpenRecordset("select * from qryCut_Over_Details where " & _
"[loop] = '" & strLoop & "'")

The problem is that it only returns a recordsource with a recordcount = 1 even tough if I build a query with the same SQL string I get a list of 50 odd entries. Why would the VB code only return a single entry?

Thanks
Roger Warne
warneri
I added a ORDER BY [loop] and it works!

Thanks all
kuifjexx
Best is to do this in steps

Dim Db as dao.database
Dim rs as dao.recordsource

SQLString = "select * from qryCut_Over_Details where " & "[loop] = '" & strLoop & "'"
Debug.print SQLString

Set db= currentdb()
Set rs = db.openrecordset(SQLString)

By using the debug.print line, you can see the contents of the SQL-string in the immediate window
I use also single quotes around the textvalue

HTH

Greetz from Belgium compute.gif

Luc aka Kuifjexx
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.