Ado Vs. Dao Question (1 Viewer)

illy2k

Registered User.
Local time
Today, 04:50
Joined
Apr 21, 2003
Messages
51
I had written alot of code in a databade using DAO instead of ADO. The code does alot of of opening of tables looking at data and then setting data = to the lookup data. This works great until split the database. And I think switching to ADO will let this work. Is there any book or online guide that helps with the syntax changes between ADO and DAO? And also do you think ADO will help the problem I have with the splitting database problem.
 

WayneRyan

AWF VIP
Local time
Today, 04:50
Joined
Nov 19, 2002
Messages
7,122
Illy,

What did splitting the database have to do with it?

Wayne
 

llkhoutx

Registered User.
Local time
Yesterday, 22:50
Joined
Feb 26, 2001
Messages
4,018
splitting the mdb has nothing to do with the problem, unless you've failed to re-link all the split tables.
 

illy2k

Registered User.
Local time
Today, 04:50
Joined
Apr 21, 2003
Messages
51
ok

Here is the type of code I am using. Whenever I split the database the code has problems. It comes up with the error data-type mismatch. There are no problems when the database is not split. Here is the code:

Dim ThisDb As Database
Dim ProdList As Recordset
Dim Lookfor As String

If IsNull(Me!DriverID) Then
Exit Sub
End If

'If not blank, look it up.
'First define DAO object variables
Set ThisDb = CurrentDb()
Set ProdList = ThisDb.OpenRecordset("Employee/Drivers")
ProdList.Index = "PrimaryKey"
Lookfor = Me![DriverID]
ProdList.Seek "=", Lookfor

If ProdList.NoMatch Then
Beep
Else
Me![DriverName] = [ProdList]![Last]
Me![DriverFirst] = [ProdList]![First]
End If
[ProdList].Close
End Sub
 

WayneRyan

AWF VIP
Local time
Today, 04:50
Joined
Nov 19, 2002
Messages
7,122
Illy,

Are you sure that the error is not "user-defined function not
supported"? (or something like that). I think that you have
to get your code in design view and check Tools --> References.
Make sure that Microsoft DAO 3.6 is checked and has a higher
priority than the ADO reference.

Wayne
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:50
Joined
Feb 19, 2002
Messages
43,223
Whe you are looking for a single specific record, there is no reason to create a recordset of an ENTIRE table and then use the seek or find methods to find the record you want, just use a query that has a parameter.

Select Last, First From ProductList Where DriverID = Forms!YourFormName!DriverID;

But BETTER STILL is to use a query as the recordsource for your form. That way you can join to the ProductList table and the First and Last fields will be in the form's recordsource!!!!!
 

Users who are viewing this thread

Top Bottom