473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Access Error: Object Variable or With block variable not set

4
Hi All,
I'm hoping someone out there can give me a hand with this problem I've got. I have an Access DB that people connect to using Access RT 2000. There are some machines that can connect through to the DB but most cannot and I can't work it out. The error people receive when trying to log onto the DB is 'Object variable or With block variable not set'.
I don't understand how some machines will connect but most won't.
I didn't create the DB, it's been around for ages and no one here knows how it works properly and I'm a complete novice with this. I had a search and saw lots of the same error but nothing that I felt comfortable with.
People get the error even with the full version of Access 2000 and XP and also RT 2003.

Any help would be greatly appreciated


Thanks in advance
Feb 15 '07 #1
5 5677
NeoPa
32,556 Expert Mod 16PB
Unfortunately, that error message just means you're trying to refer to an object variable that is unset.
Practically, it could mean anything.
We really have nothing to work on I'm afraid.
Feb 15 '07 #2
mekon
4
Thanks for the reply NeoPa, very quick
Would it help if I posted the code? I'll put it in anyway in case it will

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnOK_Click()
  2. Dim FldDef As Field, IndexDef As Index
  3. Dim holdtime, i As Integer
  4. Dim x
  5.  
  6.     On Error GoTo btnOK_Click_Err
  7.     DoCmd.Hourglass True
  8.  
  9.     '*** beep and exit if txtUserID and txtUserPassword are empty
  10.     If txtUserID & "" = "" Or txtUserPassword & "" = "" Then
  11.        Beep
  12.        GoTo Exit_btnOK_Click
  13.     End If
  14.  
  15.  
  16.     '*** check user table for Access level and Owner ID of current user
  17.     txtAccessLevel = DLookup("AccessLevel", "tblUsers", "[UserID] = forms![frmLogon]![txtUserID] and [UserPassword] = forms![frmLogon]![txtUserPassword]")
  18.     txtOwnerID = DLookup("OwnerID", "tblUsers", "[UserID] = forms![frmLogon]![txtUserID] and [UserPassword] = forms![frmLogon]![txtUserPassword]")
  19.  
  20.     '*** if user ID or Pass word is invalid, display message
  21.     If (IsNull(txtAccessLevel)) Then      '*** User group does not exist
  22.        MsgBox "Invalid Signon Attempt, check your user name and password.", 16, Me.Caption
  23.     Else
  24.        '*** AH set the current section name to
  25. '       gOwnerName = DLookup("Owner", "tlkpValidOwners", "OwnerID = forms![frmLogon]![txtOwnerID]")
  26.        If (IsNull(gOwnerName = DLookup("Owner", "tlkpValidOwners", "OwnerID = " & txtOwnerID))) And (txtOwnerID = 255) Then
  27.           gOwnerName = "Admin"
  28.        Else
  29.           gOwnerName = DLookup("Owner", "tlkpValidOwners", "OwnerID = " & txtOwnerID)
  30.        End If
  31.        gFormRecordSource = ""
  32.        Me.Visible = False   '*** Hide the logon form but not close it, because it contain some values used by other parts of the system
  33.  
  34.        '*** Set global variables
  35.        gCRLF = Chr$(13) & Chr$(10)
  36.        Set gThisDB = CurrentDb()
  37.  
  38.        On Error Resume Next     '*** in case of error like path not exist for Dir() and path already exist for Mkdir
  39.        If Dir(conLOCALDB_NAME) = "" Then  '*** create a temporary database on local drive if not already exist
  40.           MkDir conLOCALDB_PATH
  41.           Set gLocalDB = DBEngine.Workspaces(0).CreateDatabase(conLOCALDB_NAME, DB_LANG_GENERAL)
  42.        Else
  43.           Set gLocalDB = DBEngine.Workspaces(0).OpenDatabase(conLOCALDB_NAME)
  44.        End If
  45.        On Error GoTo btnOK_Click_Err
  46.  
  47.       '*** create a temporary table(attached) and a qry in this database for current user to hold selected records
  48.        txtLogonTime = Now
  49.        gFilterQueryName = "qry" & Format(Now, "ddhhnnss")
  50.        gFilterTableName = "tbl" & Format(Now, "ddhhnnss")
  51.        Set TempQry = gThisDB.CreateQueryDef(gFilterQueryName, "SELECT DISTINCTROW tblClients.* FROM " & gFilterTableName & " INNER JOIN tblClients ON " & gFilterTableName & ".ClientID = tblClients.ClientId;")
  52.        Set AttachedTbl = gThisDB.CreateTableDef(gFilterTableName)
  53.        AttachedTbl.Connect = ";DATABASE=" & conLOCALDB_NAME
  54.        AttachedTbl.SourceTableName = conLOCALTBL_NAME
  55.  
  56.        On Error Resume Next
  57.        gThisDB.TableDefs.Append AttachedTbl
  58.        If Err > 0 Then
  59.           On Error GoTo btnOK_Click_Err
  60.           Set LocalTbl = gLocalDB.CreateTableDef(conLOCALTBL_NAME)
  61.           '*** Create a field call ClientID
  62.           Set FldDef = LocalTbl.CreateField("ClientID", DB_LONG)
  63.           LocalTbl.Fields.Append FldDef
  64.           '*** Save TableDef definition by appending it to TableDefs collection.
  65.           gLocalDB.TableDefs.Append LocalTbl
  66.           '*** Create index field in the temporary table in work database
  67.           Set IndexDef = LocalTbl.CreateIndex("ClientID")
  68.           Set FldDef = IndexDef.CreateField("ClientID")
  69.           IndexDef.Primary = True
  70.           IndexDef.Required = True
  71.           IndexDef.Fields.Append FldDef
  72.           '*** Save Index definition by appending it to Indexes collection.
  73.           LocalTbl.Indexes.Append IndexDef
  74.           gThisDB.TableDefs.Append AttachedTbl
  75.        End If
  76.        On Error GoTo btnOK_Click_Err
  77.  
  78.        '***DoCmd RunSQL "INSERT INTO tblLog ( UserName, LogonTime, LogoffTime ) VALUES (" & conDOUBLE_QUOTES & forms![frmLogon]![txtUserID] & conDOUBLE_QUOTES & "," & conDOUBLE_QUOTES & HoldTime & conDOUBLE_QUOTES & ", null)"
  79.        DoCmd.SetWarnings False
  80.        DoCmd.OpenQuery "qryWriteLogonLog"
  81.        DoCmd.SetWarnings True
  82.  
  83.        DoCmd.Hourglass False
  84.  
  85.        'This only applied for special logon for ******** to transfer  records.
  86.        If Forms!frmLogon!txtAccessLevel = 8 Then     '*** DOC SUPP user
  87. '**         x = TransferDocSuppText("qryDocSuppSingleLabel", "C:\personal\address\docsu.txt")
  88. '**         x = TransferDocSuppText("qryDocSuppSingleLabel", "C:\docs\docsu.txt")
  89. '**         x = TransferDocSuppText("C:\docs\")
  90.           x = TransferDocSuppText("qryDocSuppSingleLabel", "G:\Div3\Interlen\Docss\temp\docsu.txt")
  91. '**          x = TransferDocSuppText("qryDocSuppSingleLabel", "\\Docslabels\labels$\docsu.txt")
  92.        End If
  93.  
  94.        '*** Open the Mainmenu
  95.  
  96.        DoCmd.OpenForm conMENUFORM
  97.        DoCmd.Maximize
  98.  
  99.     End If
  100.  
  101. Exit_btnOK_Click:
  102.     DoCmd.Hourglass False
  103.     Exit Sub
  104.  
  105. btnOK_Click_Err:
  106.     MsgBox Error$, , Me.Caption
  107.     Resume Exit_btnOK_Click
  108. End Sub

Thanks again
Feb 15 '07 #3
ADezii
8,834 Expert 8TB
Thanks for the reply NeoPa, very quick
Would it help if I posted the code? I'll put it in anyway in case it will

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnOK_Click()
  2. Dim FldDef As Field, IndexDef As Index
  3. Dim holdtime, i As Integer
  4. Dim x
  5.  
  6.     On Error GoTo btnOK_Click_Err
  7.     DoCmd.Hourglass True
  8.  
  9.     '*** beep and exit if txtUserID and txtUserPassword are empty
  10.     If txtUserID & "" = "" Or txtUserPassword & "" = "" Then
  11.        Beep
  12.        GoTo Exit_btnOK_Click
  13.     End If
  14.  
  15.  
  16.     '*** check user table for Access level and Owner ID of current user
  17.     txtAccessLevel = DLookup("AccessLevel", "tblUsers", "[UserID] = forms![frmLogon]![txtUserID] and [UserPassword] = forms![frmLogon]![txtUserPassword]")
  18.     txtOwnerID = DLookup("OwnerID", "tblUsers", "[UserID] = forms![frmLogon]![txtUserID] and [UserPassword] = forms![frmLogon]![txtUserPassword]")
  19.  
  20.     '*** if user ID or Pass word is invalid, display message
  21.     If (IsNull(txtAccessLevel)) Then      '*** User group does not exist
  22.        MsgBox "Invalid Signon Attempt, check your user name and password.", 16, Me.Caption
  23.     Else
  24.        '*** AH set the current section name to
  25. '       gOwnerName = DLookup("Owner", "tlkpValidOwners", "OwnerID = forms![frmLogon]![txtOwnerID]")
  26.        If (IsNull(gOwnerName = DLookup("Owner", "tlkpValidOwners", "OwnerID = " & txtOwnerID))) And (txtOwnerID = 255) Then
  27.           gOwnerName = "Admin"
  28.        Else
  29.           gOwnerName = DLookup("Owner", "tlkpValidOwners", "OwnerID = " & txtOwnerID)
  30.        End If
  31.        gFormRecordSource = ""
  32.        Me.Visible = False   '*** Hide the logon form but not close it, because it contain some values used by other parts of the system
  33.  
  34.        '*** Set global variables
  35.        gCRLF = Chr$(13) & Chr$(10)
  36.        Set gThisDB = CurrentDb()
  37.  
  38.        On Error Resume Next     '*** in case of error like path not exist for Dir() and path already exist for Mkdir
  39.        If Dir(conLOCALDB_NAME) = "" Then  '*** create a temporary database on local drive if not already exist
  40.           MkDir conLOCALDB_PATH
  41.           Set gLocalDB = DBEngine.Workspaces(0).CreateDatabase(conLOCALDB_NAME, DB_LANG_GENERAL)
  42.        Else
  43.           Set gLocalDB = DBEngine.Workspaces(0).OpenDatabase(conLOCALDB_NAME)
  44.        End If
  45.        On Error GoTo btnOK_Click_Err
  46.  
  47.       '*** create a temporary table(attached) and a qry in this database for current user to hold selected records
  48.        txtLogonTime = Now
  49.        gFilterQueryName = "qry" & Format(Now, "ddhhnnss")
  50.        gFilterTableName = "tbl" & Format(Now, "ddhhnnss")
  51.        Set TempQry = gThisDB.CreateQueryDef(gFilterQueryName, "SELECT DISTINCTROW tblClients.* FROM " & gFilterTableName & " INNER JOIN tblClients ON " & gFilterTableName & ".ClientID = tblClients.ClientId;")
  52.        Set AttachedTbl = gThisDB.CreateTableDef(gFilterTableName)
  53.        AttachedTbl.Connect = ";DATABASE=" & conLOCALDB_NAME
  54.        AttachedTbl.SourceTableName = conLOCALTBL_NAME
  55.  
  56.        On Error Resume Next
  57.        gThisDB.TableDefs.Append AttachedTbl
  58.        If Err > 0 Then
  59.           On Error GoTo btnOK_Click_Err
  60.           Set LocalTbl = gLocalDB.CreateTableDef(conLOCALTBL_NAME)
  61.           '*** Create a field call ClientID
  62.           Set FldDef = LocalTbl.CreateField("ClientID", DB_LONG)
  63.           LocalTbl.Fields.Append FldDef
  64.           '*** Save TableDef definition by appending it to TableDefs collection.
  65.           gLocalDB.TableDefs.Append LocalTbl
  66.           '*** Create index field in the temporary table in work database
  67.           Set IndexDef = LocalTbl.CreateIndex("ClientID")
  68.           Set FldDef = IndexDef.CreateField("ClientID")
  69.           IndexDef.Primary = True
  70.           IndexDef.Required = True
  71.           IndexDef.Fields.Append FldDef
  72.           '*** Save Index definition by appending it to Indexes collection.
  73.           LocalTbl.Indexes.Append IndexDef
  74.           gThisDB.TableDefs.Append AttachedTbl
  75.        End If
  76.        On Error GoTo btnOK_Click_Err
  77.  
  78.        '***DoCmd RunSQL "INSERT INTO tblLog ( UserName, LogonTime, LogoffTime ) VALUES (" & conDOUBLE_QUOTES & forms![frmLogon]![txtUserID] & conDOUBLE_QUOTES & "," & conDOUBLE_QUOTES & HoldTime & conDOUBLE_QUOTES & ", null)"
  79.        DoCmd.SetWarnings False
  80.        DoCmd.OpenQuery "qryWriteLogonLog"
  81.        DoCmd.SetWarnings True
  82.  
  83.        DoCmd.Hourglass False
  84.  
  85.        'This only applied for special logon for ******** to transfer  records.
  86.        If Forms!frmLogon!txtAccessLevel = 8 Then     '*** DOC SUPP user
  87. '**         x = TransferDocSuppText("qryDocSuppSingleLabel", "C:\personal\address\docsu.txt")
  88. '**         x = TransferDocSuppText("qryDocSuppSingleLabel", "C:\docs\docsu.txt")
  89. '**         x = TransferDocSuppText("C:\docs\")
  90.           x = TransferDocSuppText("qryDocSuppSingleLabel", "G:\Div3\Interlen\Docss\temp\docsu.txt")
  91. '**          x = TransferDocSuppText("qryDocSuppSingleLabel", "\\Docslabels\labels$\docsu.txt")
  92.        End If
  93.  
  94.        '*** Open the Mainmenu
  95.  
  96.        DoCmd.OpenForm conMENUFORM
  97.        DoCmd.Maximize
  98.  
  99.     End If
  100.  
  101. Exit_btnOK_Click:
  102.     DoCmd.Hourglass False
  103.     Exit Sub
  104.  
  105. btnOK_Click_Err:
  106.     MsgBox Error$, , Me.Caption
  107.     Resume Exit_btnOK_Click
  108. End Sub

Thanks again
__1 gThisDB and gLocalDB are Global Object Variables. Are they Declared as 'Public' in a Standard Code Module?
__2 By the code's naming convention, TempQry, AttachedTable, and LocalTbl are not Global Object Variables (not prefaced with g) but I do not see them dimensioned within the Procedure. Are they dimensioned within the Form's Class Module?
__3 If the answers to the previous 2 questions are Yes, the best option for you would be to enter a Breakpoint at the 1st executable line of code within the Procedure, Single Step through the code, and pinpoint the exact line with the Error is occurring.
Feb 16 '07 #4
mekon
4
I'm not sure how to check the first two points but we put message boxes through the script to see where it got it and it fails here

Set LocalTbl = gLocalDB.CreateTableDef(conLOCALTBL_NAME)
Feb 16 '07 #5
mekon
4
Solved it - thanks for your help.

The problem was that it was trying to write to a temporary space on the D:\. We never used to have the DB do that but someone changed it. The problem was happening because sometimes the CD drive took the D:\ or the D:\ partition wouldn't be formatted.

Thanks again
Feb 16 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ike | last post by:
Anyone knows what cuases this under 6.0 ? -Ike
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
4
by: majo | last post by:
Hi, I had posted this once earlier, but couldnt get my problem solved. When i run an asp.net application in windows 2003 server with IIS 6.0, it "SOMETIMES" gives me the below given error....
9
by: axs221 | last post by:
I am trying to move some of our large VBA Access front-end file into ActiveX DLL files. I created two DLL files so far, one was a module that contains code to integrate into the QuickBooks...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
3
by: Newbie19 | last post by:
I'm trying to get a list of all subfolders in a folder on a share drive, but I keep on getting this error message: Object variable or With block variable not set. Description: An unhandled...
1
by: akaess | last post by:
I am trying to merge information from the the database into word documents using the following methods but it keeps giving the error 91: Object Variable or With Block Variable not set. could anybody...
2
by: akaess | last post by:
Hey everybody I am currently trying to merger data from a form in MS access but it keeps giving me the error 91: Object variable or with block variable not set. could somebody please look at the code...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.