Access form not opening

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vasago
    New Member
    • Mar 2014
    • 46

    Access form not opening

    I recently changed my code from Dlookup to opening a recordset. This is my first time using a record set and having issues opening the form now. When I click to open the form nothing happens. No errors and it doesn't load

    Here is the opening code

    Code:
    Private Sub Form_Load()
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim strRst As String
    Dim strCriteria As String
    
    strCriteria = "Employee='" & Forms![Royal time Stamp]![Driver] & "' And [Date]=#" & Date & "# And [Trip Sign Off]=0"
    
    Set db = CurrentDb
    strRst = "SELECT [Punch ID] " & _
             "FROM [Copy of Employee Work Statistics1] " & strCriteria
    Set rst = db.OpenRecordset(strRst, dbOpenDynaset)
     
    [Punch ID] = rst![Punch ID]
    [Type of Work] = rst![Type of Work]
    If [Type of Work] = "" Then
    Else
    Me.[Type of Work].Locked = True
    [Trip_S_on] = rst![Trip Sign On]
    If [Type of Work] = "Transportation Specialist" Then
    Me.[bus number].Visible = True
    [bus number] = rst![bus number]
    Me.[bus number].Locked = True
    
    Me.Route.Visible = True
    [Route] = rst![Route]
    Me.Route.Locked = True
    Else
    Me.Route.Locked = False
    Me.School.Locked = False
    Me.[bus number].Locked = False
    End If
    If [Route] = "field Trip" Then
    Me.[School].Visible = True
    [School] = rst!School
    Me.School.Locked = True
    Else
    Me.School.Locked = False
    End If
    End If
    
    
    'At the end of your code, close what you open
    'and release what you set
    rst.Close
    Set db = Nothing
    Set rst = Nothing
    
    
    End Sub
    Thanks for your help,
    Vasago
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    Are you trying to open the form from the navigation pane, or from a button that you created?

    Comment

    • Vasago
      New Member
      • Mar 2014
      • 46

      #3
      Running into the same issue if I use my created button or navigation pane to open.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Place a STOP at line6 of the code.
        Execute/Open the form
        You should go into debug mode at this point in your code.
        [F8] to step your code until you either find the error or the line the form closes on.


        And [Date]=#"
        petpeeve:
        -alphanumeric this is very importaint to keep in mind when nameing fields, alphanumeric and preferably no spaces just underscores:
        Access 2007 reserved words and symbols
        AllenBrowne- Problem names and reserved words in Access


        (petPeeves are nummmy; however, they get tough and stringy if you let them grow too big! (^_^) )
        Last edited by zmbd; Apr 7 '14, 09:06 PM.

        Comment

        • Vasago
          New Member
          • Mar 2014
          • 46

          #5
          Thank you for your help. I tried all of the above with no luck. Load a backed-up version and haven't had a problem since

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            I can't count the number of times a backup has been the life saver. Hence my mantra to Backup, never work on the production version, never work on the only copy of the development version - always a copy.

            You could try the compact/repair on the original; however, that maybe a moot-point (^_^)

            Comment

            Working...