Why won't you work on Access 2010, but you run fine on 2003??

TheWanderer

New member
Local time
Today, 13:22
Joined
Feb 3, 2013
Messages
7
I have a lovely bit of code I use as a login for databases. I didn't write it, I found it on the internet. It used to work fine, but now that I have Access 2010, it doesn't like it and gives me a run time error.(run-time error 3314 You must enter a value in the 'TableEmployees.EmployeeID' field. Does anyone know what I should change the code to, in order for it to work? It says it doesn't like the Me.Dirty=False line but apparently it is a known fault.

The reason I liked this code so much, is that the users can set their passwords on their first use of the database and if they forget it, it's easy enough to delete it and they can start again.

Any help would be much appreciated, I have spent hours on this so far.

Code:
    Option Compare Database
 
Private Sub ChooseEmployee_AfterUpdate()
   
    Filter = "(((TableEmployees.EmployeeID)=[Forms]![FormChooseEmployee]![ChooseEmployee]))"
    FilterOn = True
   
    [Password1] = Null
    [Password2] = Null
    [OK].Enabled = True
    [Password1].Visible = True
    [Password1].SetFocus
    If [Forms]![FormChooseEmployee]![ChooseEmployee].Column(2) = "" Then
        [Password2].Visible = True
        MsgBox "Please set your password by entering it in both the fields shown.", vbOKOnly
    Else
        [Password2].Visible = False
    End If
   
End Sub
 
Private Sub Exit_Click()
 
    DoCmd.Quit
 
End Sub
 
Private Sub Form_Open(Cancel As Integer)
   
    Filter = "False"
    FilterOn = True
 
End Sub
 
Private Sub OK_Click()
 
    If IsNull([Password1]) Then MsgBox "Enter a password.", vbOKOnly: [Password1].SetFocus: Exit Sub
 
    If [Password2].Visible = True Then
        If [Password1] = [Password2] Then
            [Password] = [Password1]
            Me.Dirty = False
            MsgBox "You must restart the application.", vbOKOnly: DoCmd.Quit
        Else
            MsgBox "Passwords do not match, please enter again.", vbOKOnly
            [Password1] = Null
            [Password2] = Null
            [Password1].SetFocus
            Exit Sub
        End If
    Exit Sub
    End If
 
    If [Password1] = [Password] Then
        [Password1].Visible = False
        [Password1] = Null
        Modal = False
        DoCmd.OpenForm "FormChooseEmployee", , , , , acHidden
        DoCmd.OpenForm "menu"
       
        'Use the employee authorisation levels (see table) to enable or disable various buttons on the Switchboard
        If [CROwner] = True Then
        
         Forms![menu]![Proc].Enabled = True
    
  
        Else
        
         Forms![menu]![Proc].Enabled = False
        
           
       End If
      
    Else
        MsgBox "Incorrect password.", vbOKOnly
        [Password1] = Null
        [Password1].SetFocus
    End If
 
End Sub
 
http://www.access-programmers.co.uk/forums/showthread.php?t=240013&highlight=Me.Dirty&page=2
This happened to me too on a legacy 2003 Access.
If you follow this discussion - Esp Page 2 - you will find a workable solution.

Mine was working until I incidentally did a vba patch update in 2007. It has honestly been too long for me to remember the details. My desktop developer had the error, the Citrix server had not been updated and still worked.

But, here is yet another example worth looking at:
http://www.access-programmers.co.uk/forums/showthread.php?t=236027&highlight=Me.Dirty

Finally, check out some of the Form level settings such as the Key Preview
And see if there is any code in the
Private Sub Form_Dirty(Cancel As Integer)
event on the form that works.

Also:
Debug.Print " is form dirty? " & Me.Dirty & " Err is " & Err.number
Add the code above a couple of places before and after things happen.
Then watch the result in your Immediate Window.
 
i would think the 2 things are connected

a - your form is bound, and somehow you are editing a new record. but the ID field has not been set

SO

b. - me.dirty = false fails, because of the same reason.
 

Users who are viewing this thread

Back
Top Bottom