Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dim db as database

Status
Not open for further replies.

budich

Programmer
Oct 7, 2000
79
ID
Hi All,

Does anyone know why Access 2000 cannot accept the line "dim .... as database" which was ok in access 97 and how to change it so can run in Access 2000 (with ADO ?).
thank's in advance
 
I believe, if you have both ADO and DAO references installed in your Access, you have to be specific when declaring your variables. For example, instead of
Code:
Dim db As Database
, you should use
Code:
Dim db As ADO.Database
.
 
Thanks snoopy75 and WP,

thank you for your reply, however I am still have some questions : is it just as simple as add word ADO in dim db as database. I have tried it but still cannot. I have tried the thread from Kathryn (of this forum) thanks Kathryn, as below :

Private Sub Command6_Click()

Dim dbs As Database
Dim strSQL As String
Dim qdf As QueryDef
Dim rst As Recordset
Dim qdfTemp As QueryDef

Set dbs = CurrentDb

strSQL = "SELECT TblJunction.ConID, TblCon.ConName, TblJunction.ProID, TblPro.ProName, TblCon.ConEmail FROM TblPro INNER JOIN (TblCon INNER JOIN TblJunction ON TblCon.ConID = TblJunction.ConID) ON TblPro.ProID = TblJunction.ProID WHERE (((TblJunction.ProID) = [ID]))ORDER BY TblJunction.ProID;"

Set qdf = dbs.CreateQueryDef("", strSQL)

qdf.Parameters!ID = Me!ProID 'fills the parameter

Set rst = qdf.OpenRecordset

rst.MoveFirst

Do Until rst.EOF

DoCmd.SendObject acSendReport, "Report1", acFormatRTF, _
rst!conemail, "", , _
"Project Status Report", , True, False

rst.MoveNext
Loop

rst.Close
Set rst = Nothing
qdf.Close
Set qdf = Nothing

End Sub

the thread is about to send an email, I have tried to add word "ADO" but still cannot. Would you please help me ?

For WP, where is the interesting article ?
thankyou,
 
Although ADO is the method for the future it can sometimes be ridiculous to upgrade legacy systems. All you really need to do to keep from having to upgrade to ADO is do a global search and replace for the following:

'As Database' Replace with 'As DAO.Database'
'As Recordset' Replace with 'As DAO.Database'

Then open a module in design view and set a reference to the Microsoft DAO 3.6 library. Magically your application will work perfectly. This is because the default for Access 97 is DAO and the default for Access 2000 is ADO but you can decide to be explicit as long as you reference the correct libraries.

Steve King Growth follows a healthy professional curiosity
 
Thank's alot Steve,

for the recordset you write :

'As Recordset' Replace with 'As DAO.Database'
is it dao.database or dao.recordset ?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top