Hi, Im trying to check a value in a table, EmpRegNo. I'm using Dlookup to check whether its there or not.
If the value is there, then I want a form to open! If not, then a msgBox to appear...
I placed a txt Box as a test to see if the dlookup was working, and the EmpregNo was been placed in it BUT my if Statement doesnt appear to work???
Sorry about this simple question
Thx
Darin
If the value is there, then I want a form to open! If not, then a msgBox to appear...
I placed a txt Box as a test to see if the dlookup was working, and the EmpregNo was been placed in it BUT my if Statement doesnt appear to work???
Sorry about this simple question
Code:
Private Sub cmdAbsences_Click()
Dim varX As String
varX = Nz(DLookup("[tEmpReg]", "tblAbsences", "[tEmpReg] = Forms![frmEmployeeNEW]!EmpRegNo"))
Me.test = varX
If Forms![frmEmployeeNEW]!EmpRegNo = Me.test Then
MsgBox "test"
On Error GoTo Err_cmdAbsences_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAbsences"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdAbsences_Click:
Exit Sub
Err_cmdAbsences_Click:
MsgBox Err.Description
Resume Exit_cmdAbsences_Click
Else
End If
End Sub
Thx
Darin