crisis2007
Technical User
I have a query that gives me the values in the T_Attendance table.The query works properly, getting its criteria from text boxes in my input form. I have this code on a command button that is supposed to give a message if I am trying to duplicate a date and a watch number:
------------
Private Sub Command0_Click()
Dim stDocName As String
Dim numActivity As Integer
Dim stLinkCriteria As String
Dim Cancel As Integer
numActivity = 0
numActivity = DCount("*", "Q_DupCheck_N1A")
If numActivity > 0 Then
MsgBox "A schedule for " & Me.txtAttendanceDate & " Watch " & Me.txtWatch & " already exists.", vbExclamation, _
"Wait a Minute!"
GoTo Exit_Command0_Click
End If
If Not IsNull(Forms!F_Input_N1A.txtAttendanceDate) Then
stDocName = "Q_Append"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Forms!F_Input_N1A.SetFocus
DoCmd.Close
Else:
MsgBox "You need to put in a date above if you want to create a new schedule", vbExclamation, "What the...?"
Cancel = True
End If
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
-------------
I get a message that pops up when I click the command button:
Run-time error '2001'
You canceled the previous operation.
Can anyone see what I am doing wrong? I have messed with this for hours now.
------------
Private Sub Command0_Click()
Dim stDocName As String
Dim numActivity As Integer
Dim stLinkCriteria As String
Dim Cancel As Integer
numActivity = 0
numActivity = DCount("*", "Q_DupCheck_N1A")
If numActivity > 0 Then
MsgBox "A schedule for " & Me.txtAttendanceDate & " Watch " & Me.txtWatch & " already exists.", vbExclamation, _
"Wait a Minute!"
GoTo Exit_Command0_Click
End If
If Not IsNull(Forms!F_Input_N1A.txtAttendanceDate) Then
stDocName = "Q_Append"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Forms!F_Input_N1A.SetFocus
DoCmd.Close
Else:
MsgBox "You need to put in a date above if you want to create a new schedule", vbExclamation, "What the...?"
Cancel = True
End If
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
-------------
I get a message that pops up when I click the command button:
Run-time error '2001'
You canceled the previous operation.
Can anyone see what I am doing wrong? I have messed with this for hours now.