Dmayes
09-13-2007, 08:05 AM
Ok so I am trying to put in some VBA code to check the Number_Of_Transactions field on the form to see if there is a number in there greater than 0 when the OK command button is clicked. If so I want it to add the record to a table if not I want a message saying enter a number and give the user a chance to enter a number before it writes the record to a table. The code below is from the OK button and it displays the message if the field is blank but it also writes it to the table with the field blank. What am I doing wrong?
Thanks!
Private Sub New_Record_Click()
On Error GoTo Err_New_Record_Click
If Number_of_Transactions > 0 Then
DoCmd.GoToRecord , , acNewRec
Else: MsgBox "Please enter a valid number"
End If
Exit_New_Record_Click:
Exit Sub
Err_New_Record_Click:
MsgBox Err.Description
Resume Exit_New_Record_Click
End Sub
Thanks!
Private Sub New_Record_Click()
On Error GoTo Err_New_Record_Click
If Number_of_Transactions > 0 Then
DoCmd.GoToRecord , , acNewRec
Else: MsgBox "Please enter a valid number"
End If
Exit_New_Record_Click:
Exit Sub
Err_New_Record_Click:
MsgBox Err.Description
Resume Exit_New_Record_Click
End Sub