Recordset VBA Programming

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This pertains to an Access 2000 database. The "Database" type in the code below ("Dim dbNucFac as Database") is an unrecognized type. I think this is caused by failing to reference the correct "dll" from the "TOOLS\Reference" menu option but I can't remember the correct reference.

I would prefer using ADO (I am familiar with Visual Basic .Net) but I'm always having problems with "references". A little help (slap in the face to straighten me up) would be appreciated. Similar coding used to work in previous Access databases

=======CODE EXAMPLE===========
Sub IsotopeAncestor(

Dim dbNucFac As Databas
Dim rsIso As Recordset ' Isotopes recordse
Dim SqlTxt As Strin

SqlTxt = "SELECT Daughters.DID, Daughters.PARENTID, ISOTOPES.RN "
& "FROM ISOTOPES INNER JOIN Daughters ON ISOTOPES.ISOID = Daughters.PARENTID "
& "GROUP BY Daughters.DID, Daughters.PARENTID, ISOTOPES.RN ORDER BY ISOTOPES.RN

dbNucFac = CurrentD
Set rsIso = dbNucFac.openrecordset(SqlTxt

End Su
 
Joe,
Check your reference to "Microsoft DAO Objects 3.6"
Jay

Joe Cletcher said:
This pertains to an Access 2000 database. The "Database" type in the code
below ("Dim dbNucFac as Database") is an unrecognized type. I think this is
caused by failing to reference the correct "dll" from the "TOOLS\Reference"
menu option but I can't remember the correct reference.
I would prefer using ADO (I am familiar with Visual Basic .Net) but I'm
always having problems with "references". A little help (slap in the face to
straighten me up) would be appreciated. Similar coding used to work in
previous Access databases.
 
Joe,
Try adding -
FldIso As Field
Jay


Joe Cletcher said:
This pertains to an Access 2000 database. The "Database" type in the code
below ("Dim dbNucFac as Database") is an unrecognized type. I think this is
caused by failing to reference the correct "dll" from the "TOOLS\Reference"
menu option but I can't remember the correct reference.
I would prefer using ADO (I am familiar with Visual Basic .Net) but I'm
always having problems with "references". A little help (slap in the face to
straighten me up) would be appreciated. Similar coding used to work in
previous Access databases.
 
Joe Cletcher said:
This pertains to an Access 2000 database. The "Database" type in the
code below ("Dim dbNucFac as Database") is an unrecognized type. I
think this is caused by failing to reference the correct "dll" from
the "TOOLS\Reference" menu option but I can't remember the correct
reference.

I would prefer using ADO (I am familiar with Visual Basic .Net) but
I'm always having problems with "references". A little help (slap in
the face to straighten me up) would be appreciated. Similar coding
used to work in previous Access databases.

=======CODE EXAMPLE============
Sub IsotopeAncestor()

Dim dbNucFac As Database
Dim rsIso As Recordset ' Isotopes recordset
Dim SqlTxt As String

SqlTxt = "SELECT Daughters.DID, Daughters.PARENTID, ISOTOPES.RN "
_ & "FROM ISOTOPES INNER JOIN Daughters ON ISOTOPES.ISOID =
Daughters.PARENTID " _ & "GROUP BY Daughters.DID,
Daughters.PARENTID, ISOTOPES.RN ORDER BY ISOTOPES.RN"

dbNucFac = CurrentDb
Set rsIso = dbNucFac.openrecordset(SqlTxt)

End Sub

First, add a reference to "Microsoft DAO 3.6 Object Library" in the
Tools -> References... dialog of the VB Editor.

Second, if you plan also to keep the default reference to ADO (ActiveX
Data Objects 2.x Library), you must disambiguate the declarations of
some objects the libraries have in common. The safest course is to
explicitly qualify the declarations of objects from either library. I
would change your declarations to:

Dim dbNucFac As DAO.Database
Dim rsIso As DAO.Recordset ' Isotopes recordset

Also, this line:
dbNucFac = CurrentDb

needs to use the Set keyword:

Set dbNucFac = CurrentDb

That ought to get it working.
 
Thanks; just knew it had to be a reference. Don't know why Access doesn't automatically include references that allow recordset access?
 
Back
Top