Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run time error with access runtime

Status
Not open for further replies.

Lightlancer

Programmer
Jul 18, 2008
88
NL
Hi,

when all of my users press Aanmelden (login)
they get an error that says:

execution of this application has stopped due to a run-time error

The code behind this button is:

Code:
'Check to see if data is entered into the UserName combo box

    If IsNull(Me.cmdNaamMedewerker) Or Me.cmdNaamMedewerker = "" Then
            MsgBox "Je moet een gebruikersnaam invoeren.", vbOKOnly, "Required Data"
            Me.cmdNaamMedewerker.SetFocus
        Exit Sub
    End If

'Check to see if data is entered into the password box

    If IsNull(Me.txtWachtwoord) Or Me.txtWachtwoord = "" Then
            MsgBox "Je moet een wachtwoord invullen.", vbOKOnly, "Required Data"
            Me.txtWachtwoord.SetFocus
        Exit Sub
    End If

'Check value of password in tblEmployees to see if this matches value chosen in combo box

    If Me.txtWachtwoord.Value = DLookup("Wachtwoord", "qryWerknemersAanmelden", "[Personeelsnummer]=" & Me.cmdNaamMedewerker.Value) Then

        Personeelsnummer = Me.cmdNaamMedewerker.Value
        
    ' Kopieer geselecteerde gebruiker naar publieke variabele
      
    gstrDezeWerknemer = Me.cmdNaamMedewerker.Column(0)
    
    ' Werknemersnumemr en afdelings-ID opslaan
    
    glngDezeWerknemerID = Me.cmdNaamMedewerker.Column(1)
    
    
    ' Controleer of deze persoon de Manager is
    
    If IsNothing(Me.cmdNaamMedewerker.Column(4)) Then
        gintIsManager = False
    Else
        gintIsManager = Me.cmdNaamMedewerker.Column(4)
    End If
    
    ' En controleer of deze persoon beheerder is
If IsNothing(Me.cmdNaamMedewerker.Column(3)) Then
        gintIsBeheerder = False
    Else
        gintIsBeheerder = Me.cmdNaamMedewerker.Column(3)
    End If
        
     ' En controleer of deze persoon Fakturatie is
     If IsNothing(Me.cmdNaamMedewerker.Column(5)) Then
        gintIsFacturatie = False
    Else
        gintIsFacturatie = Me.cmdNaamMedewerker.Column(5)
    End If
    
    
    ' Controleren wat de gebruiker mag en wat niet mag
    ' Rapport
         If IsNothing(Me.cmdNaamMedewerker.Column(7)) Then
        gintIsRapport = False
    Else
        gintIsRapport = Me.cmdNaamMedewerker.Column(7)
    End If
    'Inkoop
         If IsNothing(Me.cmdNaamMedewerker.Column(8)) Then
        gintIsInkoop = False
    Else
        gintIsInkoop = Me.cmdNaamMedewerker.Column(8)
    End If
    'Bestel
         If IsNothing(Me.cmdNaamMedewerker.Column(9)) Then
        gintIsBestel = False
    Else
        gintIsBestel = Me.cmdNaamMedewerker.Column(9)
    End If
    'Leverancier(Lev)
         If IsNothing(Me.cmdNaamMedewerker.Column(10)) Then
        gintIsLev = False
    Else
        gintIsLev = Me.cmdNaamMedewerker.Column(10)
    End If
    'Storing Wijzigen(Storing)
         If IsNothing(Me.cmdNaamMedewerker.Column(11)) Then
        gintIsStoring = False
    Else
        gintIsStoring = Me.cmdNaamMedewerker.Column(11)
    End If
    'Fillialen
         If IsNothing(Me.cmdNaamMedewerker.Column(12)) Then
        gintIsFillialen = False
    Else
        gintIsFillialen = Me.cmdNaamMedewerker.Column(12)
    End If
    'Afdelingen (Afd)
         If IsNothing(Me.cmdNaamMedewerker.Column(13)) Then
        gintIsAfd = False
    Else
        gintIsAfd = Me.cmdNaamMedewerker.Column(13)
    End If
    'KPN
         If IsNothing(Me.cmdNaamMedewerker.Column(14)) Then
        gintIsKPN = False
    Else
        gintIsKPN = Me.cmdNaamMedewerker.Column(14)
    End If
    'Gebruikers
         If IsNothing(Me.cmdNaamMedewerker.Column(15)) Then
        gintIsGebruikers = False
    Else
        gintIsGebruikers = Me.cmdNaamMedewerker.Column(15)
    End If
    'Borent
         If IsNothing(Me.cmdNaamMedewerker.Column(16)) Then
        gintIsBorent = False
    Else
        gintIsBorent = Me.cmdNaamMedewerker.Column(16)
    End If
    'Voorraad
         If IsNothing(Me.cmdNaamMedewerker.Column(17)) Then
        gintIsVoorraad = False
    Else
        gintIsVoorraad = Me.cmdNaamMedewerker.Column(17)
    End If
    'Taken
         If IsNothing(Me.cmdNaamMedewerker.Column(18)) Then
        gintIsTaken = False
    Else
        gintIsTaken = Me.cmdNaamMedewerker.Column(18)
    End If
    ' elk formulier die gekoppelt wordt aan deze variabelen, kijkt dus eigenlijk wat wel en niet mag per gebruiker. deze worden opgeslagen.
    
      
    
    ' Ververs de gegevens op de linten
   If Not (gobjRibbon1 Is Nothing) Then
        gobjRibbon1.InvalidateControl "lblWelkom"
        gobjRibbon1.InvalidateControl "lblHaalRechten"
  End If
    
   If Not (gobjRibbon2 Is Nothing) Then
        gobjRibbon2.InvalidateControl "lblWelkom"
        gobjRibbon2.InvalidateControl "lblHaalRechten"
    End If
    
    

'Close logon form and open splash screen
        
        DoCmd.Close acForm, "frmAanmelden", acSaveNo
        DoCmd.OpenForm "Home"

        Else
        MsgBox "Wachtwoord onjuist.  Probeer opnieuw.", vbOKOnly, "Invalid Entry!"
        Me.txtWachtwoord.SetFocus
    End If
    
'If User Enters incorrect password 3 times database will shutdown
    
    intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
        MsgBox "You do not have access to this database.  Please contact your system administrator.", vbCritical, "Restricted Access!"
        Application.Quit
    End If

It only occurs with user that use Access 2007 Runtime, users like me that have the full version of access 2007 dont have this error....

Any ideas??

I tried to repackage the database but that doesnt work.
 
oh my goodness.

the best thing i can suggest is adding an error handling routine that displays the error so we can get a clue?

JB

 
at start of code block

on error goto ErrHandler


and then, just before End Sub....


Code:
ErrQuit:
Exit sub

Errhandler:
msgbox error
resume ErrQuit

end sub

JB
 
Then the error must be happening in another piece of code. I don't have time to read your code i'm afraid but look at where you call other subs or functions. Put error checking on ALL of them and it will tell you the drama

Very soon you'll be able to tell us the normal "I Solved it!" :)

JB
 
i tried to find the error, no luck, the only thing this code is doing is going to the form Home, and if i put the error code there, there is still no error message.....
 
It will be tedious but try putting at spaces (every 10 lines of so) in your code:

Msgbox("1")
...
Msgbox("2")
...
Msgbox("3")
...
etc

Send the version to the user and tell them what number they get to before it bombs. Then increase the frequency of the msgboxes in that area to isolate a line. When you've done that we can have an educated guess

JB
 
when i try the msgbox method, then on the onfocus event i put msgbox "focus"
and then the onclick event starts,
and the first code that is in the onclick event is:
msgbox "1"
and even that he wouldnt show me....
so the error is between the onfocus event wich is empty except for the msgbox, and the onclick event.......
 
i supect a missing reference which would suggest lots of code will have drama.

Are there any other form or control events associated with this control? If not then just test further in smaller and smaller parts. Send your users a db that just has one form, with the one control, and whatever is required for that to execute. Add parts until you isolate the problem

JB
 
i tried, to delete all code, and just put in the onclick event,
docmd.close,
and openform

then it works......

but that still doesnt explane why the first msgbox isnt shown.....
 
forgot to tell that this database worked before....... all new code that has entered in the update has been deleted, this is de code that has worked before with runtime.......

Also a reminder that the code WORKS with a full version of access......

Only with runtime access it doesnt
 
it works with docmd.close, doesn't work with all code

add your code bit by bit until you isolate the problem. Sorry, but really cant help until you work ou what line is causing the problem

JB
 
Got more info now,

This code seems to create the error, also when inserting an error msgbox, it will not show the errorcode.

Code:
If DLookup("[Volledige Update]", "tblstatus") = True Then
DoCmd.Close , , acSaveNo
DoCmd.OpenForm "frmVUpdate", , , , , acDialog
Else
If DLookup("Update", "tblstatus") = True Then
DoCmd.Close , , acSaveNo
DoCmd.OpenForm "frmUpdate", , , , , acDialog
Else
If DLookup("Uitgeschakelt", "tblstatus") = True Then
DoCmd.Close , , acSaveNo
DoCmd.OpenForm "frmUitgeschakelt", , , , , acDialog
Else

End If
End If

End If

when i delete this code for this form (first form in DB) de database doesnt show any errors on this form, offcourse this piece of code is in every form i have..........
 
docmd.close with blank parameters will close the active object - eg, the object running the code. try:

Code:
If DLookup("[Volledige Update]", "tblstatus") = True Then
    DoCmd.OpenForm "frmVUpdate", , , , , acDialog
    DoCmd.Close "formnamee",acform , acSaveNo

Else
  If DLookup("Update", "tblstatus") = True Then
        DoCmd.OpenForm "frmUpdate", , , , , acDialog
        DoCmd.Close "formname",acform , acSaveNo
  Else
     If DLookup("Uitgeschakelt", "tblstatus") = True Then
         DoCmd.OpenForm "frmUitgeschakelt", , , , , acDialog
         DoCmd.Close "formname", acform, acSaveNo
     End If
   End If
End If

indenting the code makes it much easier to read

JB
 
Still gives the runtime error, also with an errormessage code, it still gives the same error,

What the function does is look if a checkbox in a table is checked,

is there another way to do this, so this error wont show.....
 
i tried to decrypt the code more into this,

Code:
If DLookup("[Volledige Update]", "tblstatus") = True Then
MsgBox "1", vbOKOnly
Else
  If DLookup("Update", "tblstatus") = True Then
  MsgBox "2", vbOKOnly
  Else
     If DLookup("Uitgeschakelt", "tblstatus") = True Then
     MsgBox "3", vbOKOnly
     Else
     MsgBox "4", vbOKOnly
     End If
   End If
End If

to see when there is an 1,2,3 or 4 msgbox,
but still no luck,
so i think this piece of the code is wrong....
Code:
If DLookup("Uitgeschakelt", "tblstatus") = True

any ideas???
 
Yess, 1 part of the error is solved, i can reach my login script again:D
Problem was a related table wich the Dlookup couldt see or something, after recreating another relation between 2 tables, de database could open again, now i still cant login,

i reduced the VBA code (in first post) to this:
Code:
'Check value of password in tblEmployees to see if this matches value chosen in combo box

    If Me.txtWachtwoord.Value = DLookup("Wachtwoord", "qryWerknemersAanmelden", "[Personeelsnummer]=" & Me.cmdNaamMedewerker.Value) Then

       

'Close logon form and open splash screen
        
        DoCmd.Close acForm, "frmAanmelden", acSaveNo
        DoCmd.OpenForm "Home"
Else
        MsgBox "Wachtwoord onjuist.  Probeer opnieuw.", vbOKOnly, "Invalid Entry!"
        Me.txtWachtwoord.SetFocus
    End If

and then the error occurs, so the error is here somewhere,
gonna try more
if someone sees it, pls tell me:D
 
When i change this
Code:
DLookup("Wachtwoord", "qryWerknemersAanmelden", "[Personeelsnummer]=" & Me.cmdNaamMedewerker.Value)
to this:
Code:
DLookup "12345"

and i put in my login form this password, then the next form opens, so the problem in somewhere in the Dlookup
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top