Pessoal, estou com um problema parecido, meu código está assim e dá o seguinte erro "Run time error 91, Object variable or With block variable not set", porque será ?
Option Explicit
Public V_Usuario As Integer
Public V_Nusuario As String
Public gWK As Workspace
Public gDB As Database
Public gRS As Recordset
Public gSQL As String
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal _
hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As _
Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Main()
If App.PrevInstance Then
MsgBox "A aplicação já se encontra aberta!", vbCritical, App.EXEName
End
End If
'Verifica se o banco de dados existe
'Se não existir, cria o banco de dados
If Dir(App.Path & "org.mdb") = Empty Then
Set gDB = gWK.CreateDatabase(App.Path & "org.mdb", dbLangGeneral, dbVersion30)
gDB.Close
gWK.Close
Set gDB = Nothing
Set gWK = Nothing
End If