Results 1 to 3 of 3
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Run-time error with Access Run-time version (MS Access 2007)

    I have come across a very odd issue with MS Access run-time. I have developed a piece of code to track the user's login and logout. It works just fine in Developer Access and does not kick out any errors. However, when the identical code is run in Access run-time it kicks out a run-time error, but no error code/description. Are there some libraries that are not recognized by Access run-time? Is there a way to define the correct libraries for run-time using VBA? Any help will be much appreciated.



    Code:
    Private Sub Form_Load()
        Dim varUserID
        Dim varLoginTime
        Dim varLoginDate
        Dim varDatabase As String
        Dim varUserCheck
        Dim varDateCheck
        Dim varDBCheck
        varDatabase = "RI"
        varLoginTime = Time
        varLoginDate = Date
        varUserID = Form_FrmMain.RV.Value
        varDateCheck = DLookup("[LoginDate]", "tblLoginTrack_RI", "[UserID] = '" & varUserID & "'")
        varDBCheck = DLookup("[DBName]", "tblLoginTrack_RI", "[UserID] = '" & varUserID & "'")
        varUserCheck = DLookup("[UserID]", "tblLoginTrack_RI", "[UserID] = '" & varUserID & "'")
        If IsNull(varUserCheck) Then
            mySQL = "INSERT INTO tblLoginTrack_RI (UserID, LoginTime, LoginDate, DBName) VALUES ('" & varUserID & "', #" & varLoginTime & "#, #" & varLoginDate & "#, '" & varDatabase & "')"
            CurrentDb.Execute mySQL, dbFailOnError
        End If
        If varUserCheck <> "" Then
            If varDateCheck = Date Then
                If varDBCheck = varDatabase Then
                    mySQL = "DELETE * FROM tblLoginTrack_RI WHERE UserID='" & varUserID & "' AND DBName='" & varDatabase & "' AND LoginDate = #" & varLoginDate & "#"
                    CurrentDb.Execute mySQL, dbFailOnError
                    mySQL = "INSERT INTO tblLoginTrack_RI (UserID, LoginTime, LoginDate, DBName) VALUES ('" & varUserID & "', #" & varLoginTime & "#, #" & varLoginDate & "#, '" & varDatabase & "')"
                    CurrentDb.Execute mySQL, dbFailOnError
                End If
            End If
            If varDateCheck <> Date Then
                mySQL = "INSERT INTO tblLoginTrack_RI (UserID, LoginTime, LoginDate, DBName) VALUES ('" & varUserID & "', #" & varLoginTime & "#, #" & varLoginDate & "#, '" & varDatabase & "')"
                CurrentDb.Execute mySQL, dbFailOnError
            End If
        End If
    End Sub
    Code:
    Private Sub Form_Close()
        Dim varUserID
        Dim varExitTime
        Dim varLoginDate
        Dim varDatabase As String
        varDatabase = "RI"
        varExitTime = Time
        varLoginDate = Date
        varUserID = Form_FrmMain.RV.Value
        mySQL = "Update tblLoginTrack_RI SET ExitTime=#" & varExitTime & "# WHERE UserID='" & varUserID & "' AND DBName='" & varDatabase & "' AND LoginDate = #" & varLoginDate & "#"
        CurrentDb.Execute mySQL, dbFailOnError
    End Sub

  2. #2
    ajetrumpet is offline Banned
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    It is always a good idea to build error traps into all of your code (functions and subs) so the runtime application can tell you what's wrong. (error number / description at the least). One thing you might want to do is include an error trap section and make a new MDE to figure it out since runtime only gives a general error with no information.

    A couple of MS articles that might be relevant:

    http://support.microsoft.com/kb/295179

    http://support.microsoft.com/kb/189366

    Also, this line of code looks to contain incorrect syntax. What is it suppose to do?
    Code:
    varUserID = Form_FrmMain.RV.Value

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Sorry for dropping the ball on this post! The code you are referring to takes the user's ID from a form that opens in the background and assigns it to the variable.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Run-time 339 when change to 2007
    By nivek in forum Access
    Replies: 1
    Last Post: 06-30-2010, 08:40 PM
  2. Run time vs Full Version
    By softspoken in forum Access
    Replies: 5
    Last Post: 04-29-2010, 08:15 AM
  3. Replies: 2
    Last Post: 11-10-2009, 02:49 PM
  4. Access Runtime 2007 Date Time Picker Vista not working
    By sailinxtc in forum Programming
    Replies: 0
    Last Post: 09-17-2008, 12:56 PM
  5. Replies: 1
    Last Post: 12-09-2005, 09:16 PM

Tags for this Thread

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