Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14

    Smile Object variable not set (Error 91)

    Can someone please look at my code and see what I am missing to get the error 91, I just upgrade this database to 2007:

    Sub SLOG(Msg As String)
    'If Forms!frmSYNCH!optLog = False Then Exit Sub


    Log.AddNew
    Log!LogDate = DATE
    Log!LogTime = Time()
    Log!Msg = Msg
    Log.Update
    MsgCount = MsgCount + 1
    End Sub

    Sub Clearlog()
    Set Log = DB.OpenRecordset("tblSynchLog")
    Do Until Log.EOF
    Log.Delete
    Log.MoveNext
    Loop
    MsgBox "LOG CLEARED"
    End Sub

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I usually have a couple of lines of code that look like this when I'm using 'DB.OpenRecordset . . .'
    Dim db As DAO.Database
    Set db = CurrentDb

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Robeen has certainly identified the problem (the DB variable never being set). That said, a far more efficient method to do what you're doing:

    CurrentDb.Execute "DELETE * FROM tblSynchLog", dbFailOnError
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14
    Thank You!!

  5. #5
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14
    How about the error on this statement?
    rivate Sub Form_Open(cancel As Integer)
    Dim db As DAO.Database
    Dim Avail As DAO.Recordset
    Dim Assg As DAO.Recordset
    Dim Idx2 As Integer
    DoCmd.Maximize
    Me.RecordSource = "tblDE" & Int(Forms!frmChooseDEShift!DEtbl)
    Me.OrderBy = "PRESSNBR"
    If IsNull(Me!ComboDownCode1) Then
    Me!DWNTIME1 = 0
    Me!DWNTIME1.Locked = True
    Me!DWNTIME1.Enabled = False
    Else
    Me!DWNTIME1.Locked = False
    Me!DWNTIME1.Enabled = True
    End If
    If IsNull(Me!ComboDownCode2) Then
    Me!DWNTIME2 = 0
    Me!DWNTIME2.Locked = True
    Me!DWNTIME2.Enabled = False
    Else
    Me!DWNTIME2.Locked = False
    Me!DWNTIME2.Enabled = True
    End If
    If IsNull(Me!ComboDownCode3) Then
    Me!DWNTIME3 = 0
    Me!DWNTIME3.Locked = True
    Me!DWNTIME3.Enabled = False
    Else
    Me!DWNTIME3.Locked = False
    Me!DWNTIME3.Enabled = True
    End If
    If Forms!frmChooseDEShift!AddOrUpdate = "U" Then
    Me!ComboSupervisors = Forms!frmChooseDEShift!Supervisor
    Me!Label184.Visible = False
    SupervisorSelected = True
    Else
    Me!ComboSupervisors.SetFocus
    End If

    Set db = CurrentDb
    Set DE = db.OpenRecordset("tblDE" & Int(Forms!frmChooseDEShift!DEtbl))
    Call LinkedTable_Open("tblShiftReliefAvailable", "idx", Avail)
    'Avail.Seek "=", Forms!frmChooseDEShift!PRODDATE, Forms!frmChooseDEShift!PRODSHIFT
    If Avail.NoMatch Then
    idx = 1
    Do Until idx > 3
    ReliefOperator(idx) = 0
    AvailableHrs(idx) = 0
    ReliefHrs(idx) = 0
    idx = idx + 1
    Loop
    Exit Sub
    End If
    idx = 1
    Do Until idx > 3
    If IsNull(Avail("operator" & idx)) Then
    ReliefOperator(idx) = 0
    Else
    ReliefOperator(idx) = Avail("operator" & idx)
    End If
    If IsNull(Avail("HRS" & idx)) Then
    AvailableHrs(idx) = 0
    Else
    AvailableHrs(idx) = Avail("HRS" & idx)
    End If
    ReliefHrs(idx) = 0
    Do Until DE.EOF
    Idx2 = 1
    Do Until Idx2 > 3
    If ReliefOperator(idx) = DE("RELIEF" & Idx2) Then _
    ReliefHrs(idx) = ReliefHrs(idx) + DE("RELIEF" & Idx2 & "HRS")
    Idx2 = Idx2 + 1
    Loop
    DE.MoveNext
    Loop
    idx = idx + 1
    Loop

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    What's the error? If it's the same one, does the function being called earlier by chance close it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14
    Yes, same 91 error, and no to function closing it.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Do you know how to set a breakpoint and step through the code so you can follow what's happening?

    http://www.baldyweb.com/Debugging.htm

    Or can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14
    working on it right now. I like your debugging document, Thanks!

  10. #10
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14
    Ok that didn't work like I thought. I keep going in circles. How do I post the database?

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Do a compact/repair, then zip and attach in the Advanced reply area.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14
    It't too big for the forum by .38KB after being zipped.

  13. #13
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14
    Still too large for the forum

  14. #14
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I did a quick scan and found that

    DE is not declared as a DAO.Recordset
    idx is not declared as an integer

    Not sure if "SupervisorSelected" is a variable or a control on a form



    Do you have the following two lines at the top of *every* code page??

    Option Compare Database
    Option Explicit

  15. #15
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14
    yes:
    Option Compare Database
    Option Explicit
    Dim db As Database
    Dim Avail As Recordset
    Dim Assg As Recordset
    Dim DE As Recordset
    Dim SupervisorSelected As Boolean
    Dim CurrentReliefOperator As Long
    Dim CurrentReliefHrs As Double
    Dim ReliefOperator(3) As Long
    Dim AvailableHrs(3) As Double
    Dim ReliefHrs(3) As Double
    Dim idx As Integer
    Dim Idx2 As Integer

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 06-12-2012, 09:52 PM
  2. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  3. Object variable or With block variable not set
    By walter189 in forum Programming
    Replies: 1
    Last Post: 07-28-2011, 08:51 AM
  4. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  5. Object variable...Jesus!
    By Baba78 in forum Access
    Replies: 8
    Last Post: 06-19-2009, 03:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums