error when trying to insert query

associates

Registered User.
Local time
Today, 14:14
Joined
Jan 5, 2006
Messages
94
Hi,

I was wondering if i could get some help here. I got error message saying "user defined - typed not defined" and it's highlighting the first line that is WorkBase as Database.

Here is my code.
Code:
    Dim WorkBase As Database
    Dim WorkRS1 As Recordset
    Dim rsNew As New ADODB.Recordset

        Set WorkBase = CurrentDb

        strSQL = "INSERT INTO [Projects](Project_ID, [OLD J_ID]) "
        strSQL = strSQL + "VALUES ('" & myProjectID & "', '" & myOldPID & "')"
        WorkBase.Execute strSQL, dbFailOnError
        WorkBase.Close

This is for Office 2003

Thank you in advance
 
Just drop the "Workbase" variable entirely and use CurrentDb throughout.

Code:
    Dim WorkRS1 As Recordset
    Dim rsNew As New ADODB.Recordset

        strSQL = "INSERT INTO [Projects](Project_ID, [OLD J_ID]) "
        strSQL = strSQL + "VALUES ('" & myProjectID & "', '" & myOldPID & "')"
        CurrentDb.Execute strSQL, dbFailOnError
        CurrentDb.Close

If you're trying to cycle through a bunch of different databases, then you have to define the collection as type Databases (note the plural) and then cycle through each database object in the database collection.
 

Users who are viewing this thread

Back
Top Bottom