|
-
May 26th, 2005, 07:11 AM
#1
Thread Starter
Member
Access and Fields of Recordsets using DAO3.6 [Resolved]
Hi,
I'm having a problem retrieving fields from a recordset when using SQL in access. My code is this
Code:
varSQL = "SELECT * FROM tblemployees"
Set db = CurrentDb
Set rs = db.OpenRecordset(varSQL, dbOpenDynaset, dbReadOnly)
rs.MoveFirst
Do While Not rs.EOF
MsgBox rs.Fields("lastcontactdate")
If rs.Fields("lastcontactdate") < varCompareDate Then
varcount = varcount + 1
rs.MoveNext
Else
rs.MoveNext
End If
Loop
the rs.fields("lastcontactdate") line always seems to bring up an error "Item not found in this collection". Any thoughts on a speedy resolution?
Last edited by Zukovsky; May 26th, 2005 at 07:56 AM.
-
May 26th, 2005, 07:39 AM
#2
Frenzied Member
Re: Access and Fields of Recordsets using DAO3.6
Make sure you have a field called lastcontactdate in tblemployees, and that it's all spelled correctly.
Then check the recordset. One way to do this is to put a Stop statement after the line Set rs = db.OpenRecordset..., then check the Locals window. You should see an entry called rs. Expand the plus sign, then the Fields plus sign. Your fields are called Item 1, Item 2, etc. Expand them until you find one with the Name value of lastcontactdate. If it's not there, it's not in your recordset.
Tengo mas preguntas que contestas
-
May 26th, 2005, 07:55 AM
#3
Thread Starter
Member
Re: Access and Fields of Recordsets using DAO3.6
Ah, you're right. Simple case of mis-spelling.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|