Hello,
I have a data entry form which can be opened in 2 ways:
A) to add a new record
Code:
Private Sub cmdAddNew_Click()
DoCmd.OpenForm "frmDE_Suppliers", , , , acFormAdd
End Sub
B) edit an existing record
Code:
Private Sub cmdEdit_Click()
DoCmd.OpenForm "frmDE_Suppliers", , , "SupplierID=" & Me.SupplierID, acFormEdit
End Sub
I want to check what mode the form is being opened in, and do stuff based on this mode. This is what I have so far:
Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo ErrHandler
If Auth(TempVars("EmployeeID"), "Suppliers", "View") = False Then
Cancel = True
Exit Sub
End If
If Me.NewRecord = False Then
If Auth(TempVars("EmployeeID"), "Suppliers", "Edit") = False Then
Cancel = True
Exit Sub
End If
Else
If Auth(TempVars("EmployeeID"), "Suppliers", "Add") = False Then
Cancel = True
Exit Sub
End If
End If
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2501
Resume Next
End Select
End Sub
But for some reason, "Me.NewRecord" returns False in both cases. Can you please help me fix this? Should I use something different than Me.NewRecord?
Thank you,
Tomas