Blank Record addition on Opening Form (1 Viewer)

BusyBeeBiker

New member
Local time
Today, 19:37
Joined
Jun 27, 2021
Messages
26
On opening access form frmPersonnel, 2 blank records are added to the underlying table tblPerson.
2021-06-29 (3).png

It only happens when the form is initially opened.

Below is the coding for this form for Open, Load and Current events

Code:
Private Sub Form_Open(Cancel As Integer)
If glbHandleErrors Then On Error GoTo ErrHandler ' Set Error Handling

Dim txtUserLogin As String ' Dimension Local Variable

Call modTracking(Me.Name, 6, Environ("ComputerName"), Environ("UserName"), "") ' Tracks Entry into Form

Call subCtrlLockUnlock(Form.Name, "", "", "UL", 8, 10, 1) ' Call Control Locking Sub-Procedureon for form

Call txtSearchRowSource(Form.Name, "", "", "txtSearch", 1) ' Set Row Source for combo control txtSearch

Call MaximiseScreen ' Maximise the Form

OpenAllDatabases True ' Set Persistent Connection (Open) to WLP System Databases.

' Me.fkTitleID.SetFocus ' Set Focus to fkTitleID
Me.txtSearch.SetFocus

If binCancelled Then
    binCancelled.Enabled = False
Else
    binCancelled.Enabled = True
End If

If binGDPR Then
    binGDPR.Enabled = False
Else
    binGDPR.Enabled = True
End If

ExitHere:   ' Any Clean Up Code
   Err.Clear
   Exit Sub
 
ErrHandler: ' ERROR HANDLING ROUTINE.
   If Err.Number <> 0 Then
       Call LogError(Err.Number, Err.Description, Forms!frmLoginscreen!fkID, Environ("UserName"), Environ("ComputerName"), "", glbHandleErrors)
      Resume ExitHere
   End If
End Sub


Private Sub Form_Load()
If glbHandleErrors Then On Error GoTo ErrHandler ' Set Error Handling

' Sets Initial Filters on Tab Pages within WLP Database.
    Dim strPersonID As Long
 
    DoCmd.ApplyFilter , "[pkPersonID]=" & Forms!frmLoginscreen!fkID ' Iniitial Person Record Loaded
    
' THIS SECTION SETS WHICH TABS A USER CAN ACCESS.
' Initial default position of all tabs on WLP System.
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgContact").Visible = False
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgPersonal").Visible = False
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgLearner1").Visible = False
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgStaff").Visible = False
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgVolunteer").Visible = False
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgHumanResource").Visible = False
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgLearner").Visible = False
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgAttendance").Visible = False
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgAdmin").Visible = False

' Set Tabs Visibility Property dependent on Security Clearance.
Select Case Forms!frmLoginscreen!numSecurityLevel
    
    Case 1 To 2 ' Support Staff
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgContact").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgPersonal").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgLearner").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgLearner1").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgAttendance").Visible = True

    Case Is = 5 'Supervisors
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgContact").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgPersonal").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgLearner1").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgStaff").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgHumanResource").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgLearner").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgAttendance").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgAdmin").Visible = True

    Case 8 To 10 ' Senior Management Team and Developer
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgContact").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgPersonal").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgLearner1").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgStaff").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgVolunteer").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgHumanResource").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgLearner").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgAttendance").Visible = True
        Forms!frmPersonnel.TabCtPersonnel.Pages("pgAdmin").Visible = True
  
End Select
    
' Set Active Tab Page to Member Tab
    Me.TabCtPersonnel = 0
    
ExitHere:   ' Any Clean Up Code
   Err.Clear
   Exit Sub
 
ErrHandler: ' ERROR HANDLING ROUTINE.
   If Err.Number <> 0 Then
       Call LogError(Err.Number, Err.Description, Forms!frmLoginscreen!fkID, Environ("UserName"), Environ("ComputerName"), "", glbHandleErrors)
      Resume ExitHere
   End If
End Sub

Private Sub Form_Current()
' Error Trapping System Initiated.
    If glbHandleErrors Then On Error GoTo Proc_Err
 
 ' Set Visible Property for Following Fields on Current Record
    Me.lblConfirmEMail.Visible = False
    Me.lblCopyPaste.Visible = False
    Me.Text154.Visible = False
 
 ' Checks whether Cancelled Boxes is Checked and if so sets enabled property to False.
' Enable/Disable Controls below.
    If Me.binCancelled = True Then
        Me.binCancelled.Enabled = False
    Else
        Me.binCancelled.Enabled = True
    End If
    
    If Me.binGDPR = True Then
        Me.binGDPR.Enabled = False
    Else
        Me.binGDPR.Enabled = True
    End If
    
' Check for No Photo Image Displayed.
    If IsNull(Me.txtPhoto) Then
        Me.txtPhoto = glbstrImageDocumentsPath & "NoPhoto.jpg"
    End If
    
' Clear Any Errors
    Err.Clear
  
' Exit Sub-Routine
    Exit Sub

Proc_Err:
' Generates Error Message
    MsgBox "Error: (" & Err.Number & ") " & Err.Description & ". E-Mail Error Number and Description to rberry425@gmail.com, quoting error number and Error Description", vbCritical
    
End Sub
Any ideas, as I am pretty stumped on this one.

Just give me a nudge in the right direction.

Buzzing off to mend a fence now.
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:37
Joined
Sep 21, 2011
Messages
10,860
Put a breakpoint on code in Form Open and follow it from there.
Who knows what all those Calls are doing ?-(
 

BusyBeeBiker

New member
Local time
Today, 19:37
Joined
Jun 27, 2021
Messages
26
Put a breakpoint on code in Form Open and follow it from there.
Who knows what all those Calls are doing ?-(
Gasman
Sometimes you can't see the wood for the trees, I have looked through all the code manually but not stepped through it, which is blindingly obvious.

Thanks for that both you and the TheDBGuy suggested the same thing.

I'm big on my circus quotes at the moment: "Spot on and you both win a coconut!!"
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:37
Joined
Oct 29, 2018
Messages
19,185
Gasman
Sometimes you can't see the wood for the trees, I have looked through all the code manually but not stepped through it, which is blindingly obvious.

Thanks for that both you and the TheDBGuy suggested the same thing.

I'm big on my circus quotes at the moment: "Spot on and you both win a coconut!!"
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:37
Joined
Sep 21, 2011
Messages
10,860
Glad you did not "shy" away from finding the problem. :)
 

Users who are viewing this thread

Top Bottom