A2K or AXP?
You need to add the Microsoft Data Access Object (DAO) 3.6 Library into the
References Collection of your database since Database is an object of DAO.
In the VBE (code) window, use the Menu Tools / References ... to get the
References Dialog.
While you are in this, remove ActiveX Data Object (ADO) Library from the
Refernces if you are not using it (if you don't know it, you are not using
it) since ADO and DAO have objects of the same class name but not
compatible, most notably Recordset.
If you don't remove ADO, you need to give the DAO Library higher priority
than ADO so that Access VBA defaults your Recordset declaration to DAO
rather than ADO. Alternatively, you can declare with full reference like:
Dim rs As DAO.Recordset
For safe coding, I always renove the ADO References AND declare with full
reference.
HTH
Van T. Dinh
MVP (Access)
Quote:
> My years of Delphi programming do not seem to help as I am trying to
> learn Access VBA :-)!
> I need to run through all of the records in a table and I believe that I
> need a variable, dbs. However, the following is not accepted:
> Dim dbs Database
> What should I use? Or am I off on the wrong foot with the skeleton below?
> Also, how do I reference the field, "FullName"?
> Many thanks for your patience (the book, "Access 2000 VBA Handbook",
> does not seem to have examples of what I want to do.
> Todd
> Function ProcessNames()
> Dim rst As Recordset
> Dim nameList As Recordset
> Dim cQuery As String
> Dim dbs ????????
> Set dbs = CurrentDb
> cQuery = "select * from AddrList "
> Set nameList = dbs.OpenRecordset(cQuery)
> DoCmd.SetWarnings True
> Do While Not nameList.EOF
> MsgBox nameList.Fields("FullName")
> Loop
> MsgBox("Finished");
> rst.Close
> nameList.Close
> End Function