Referencing Tables

DeutchBose

Board Regular
Joined
Mar 22, 2004
Messages
83
I am able to run following in Access '97, but not in Access XP:

Dim db as Database
Dim tbl as Table
Dim pDate as Date

Set db as CurrentDb()
Set tbl as db.OpenTable("Table1")

tbl.MoveFirst
If Not tbl.EOF Then
pDate = tbl.ProcessingDate
End If

This code works fine for Access 97, but after converting to XP, it doesn't recognize 'Table' as a 'user-defined type'. If I change Table to Recordset, it then won't recognize the field name 'ProcessingDate' in the table.

The only difference as far as I can tell is that '97 uses the DAO 2.5/3.5 Object Library, while XP is using the DAO 3.6 Object Library.

Any ideas?

Thanks.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Here's a snippet of code I used to do something similar;

Dim wrkODBC As Workspace
Dim dbsNorthwind As Database
Dim conPubs As Connection
Dim rstTemp As Recordset
Dim rstTemp2 As Recordset

Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set dbsNorthwind = wrkJet.OpenDatabase("chris.mdb")

Set rstTemp = dbsNorthwind.OpenRecordset("LinkTable", dbOpenForwardOnly)

If Not rstTemp.EOF Then
Debug.Print rstTemp.Fields(1)
End If


HTH

Chris
 
Upvote 0
Check Tools | References iin a module. Is DAO above ADO in the list of ticked items? If not, change the order and try again.

Denis
 
Upvote 0

Forum statistics

Threads
1,221,787
Messages
6,161,960
Members
451,734
Latest member
Anmol Pandey19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top