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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 97 to use DAO

Status
Not open for further replies.

cg084

Technical User
Joined
May 3, 2002
Messages
67
Location
GB
Hi,

I am developing a database or two and currently they only have access 97 installed. Several of the template databases i have used are access 2000. Rather than going through all my work again i need to be able to add the reference library for DAO in to this database. Is there anywhere i may be able to get a hold of it? Failing that i will have to recode my VB. Please find below the current Access2K code. The code is for a combo box that should a value that is not in the table that the combo box is linked to it will ask to confirm whether the value should be addded to the table.

Private Sub cboTest_NotInList(NewData As String, Response As Integer)
If MsgBox("Do you really want to add this item?", vbQuestion + vbYesNo, sPrgName) = vbYes Then
Dim DB As Database
Dim sSQL As String
sSQL = "INSERT INTO
(FIELD_Name) VALUES(" & Chr(34) & (cboTest.Text) & Chr(34) & ")"
Set DB = CurrentDb

DB.Execute sSQL
DB.Close
Set DB = Nothing
' Continue without displaying default error message.
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
 
go into the code shown
menu bar/tools/References/micro~3.6DAO
Tick on it's little box

Hope this helps
Hymn
 
Hi,

Still no joy. The reference has been placed in now but i get the message runtime error 13 Type Mismatch. When you click on Debug it takes you to the following line

Set DB = CurrentDb

I really cannot see any problem it works fine in my Access 2k db but not when it has been converted and the reference libraries added.
 
try
dim db as DAO.database

Hope this helps
Hymn
 
be explicit when declaring Database and Recordset objects in 2K and XP when you want to use DAO

Dim db as DAO.Database

or

Dim rs as DAO.Recordset

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top