Hi
It has been a year or so since I have done any serious programming in Access and I cannot even remember the basics! I need to find details from a table against a particular part number but the code I have used is something I found in one of my old Access 97 databases. I have enabled DAO 3.6 but the code still does not want to run. It compiles ok, but I get a Type mismatch message on the Set r1 line.
Can anyone help please, the simple code is below:
Dim db As Database
Dim r1 As Recordset
Set db = DBEngine.Workspaces(0).Databases(0)
Set r1 = db.OpenRecordset("partlist", dbOpenTable)
r1.MoveFirst
Do Until r1.EOF
If r1!Partno = Me!Partno Then
Me!Description = r1!Description
Me!Weight = r1!Weight
Me![Cost Price] = r1![Cost Price]
Me!Price = r1!Price
Me![Annual Subscription Price] = r1![Annual Subscription Price]
r1.Close
GoTo End_Loop
End
Else
r1.MoveNext
End If
Loop
Thanks
It has been a year or so since I have done any serious programming in Access and I cannot even remember the basics! I need to find details from a table against a particular part number but the code I have used is something I found in one of my old Access 97 databases. I have enabled DAO 3.6 but the code still does not want to run. It compiles ok, but I get a Type mismatch message on the Set r1 line.
Can anyone help please, the simple code is below:
Dim db As Database
Dim r1 As Recordset
Set db = DBEngine.Workspaces(0).Databases(0)
Set r1 = db.OpenRecordset("partlist", dbOpenTable)
r1.MoveFirst
Do Until r1.EOF
If r1!Partno = Me!Partno Then
Me!Description = r1!Description
Me!Weight = r1!Weight
Me![Cost Price] = r1![Cost Price]
Me!Price = r1!Price
Me![Annual Subscription Price] = r1![Annual Subscription Price]
r1.Close
GoTo End_Loop
End
Else
r1.MoveNext
End If
Loop
Thanks