473,786 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access Error: Object Variable or With block variable not set

4 New Member
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 5709
NeoPa
32,578 Recognized Expert Moderator MVP
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 New Member
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 Recognized Expert Expert
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 New Member
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.Create TableDef(conLOC ALTBL_NAME)
Feb 16 '07 #5
mekon
4 New Member
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
74329
by: Ike | last post by:
Anyone knows what cuases this under 6.0 ? -Ike
14
5423
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 7.2 environment, the choices the optimizer makes often seem flaky. But this last example really floored me. I was hoping someone could explain why I get worse response time when the optimizer uses two indexes, than when it uses one. Some context:
6
4753
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 appreciated. Thanks in advance
4
240
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. Please note that it gives this error only ONCE IN A WHILE. To test if this error has anything to do with the server, I xcopied the same application to a new virtual directory in the same server.
9
3102
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 accounting software. Another has general utilities. I tried referencing the utilities dll, and it shows up in the object explorer. I instantiated an instance of the class and now it shows up all okay in the Intellisense. Whenever I try to run a simple...
4
12443
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 this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
3
3261
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 exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object variable or With block...
1
3028
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 helpe me out? '**************************************************************** 'MailMerge method opens specified Word document and merges fields 'specified within the document with the Access fields located in 'the specified query FRM00034...
2
5655
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 below and please guide me to a solution. Thank you! '**************************************************************** 'MailMerge method opens specified Word document and merges fields 'specified within the document with the Access fields...
0
10164
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.