Access Code

Associate
Joined
10 Jan 2006
Posts
483
I have writtien a piece of code in MS access in order to create payments for a specific month. The proble i have with it is that my validation rule does not seem to work and when i leave the date field blank it does nothing, can anyone find the bug?

Private Sub cmdMakeSubs_Click()
Dim db As Database
Dim Amount As Currency

Set db = CurrentDb
Dim rcdsSubsDue As DAO.Recordset
Dim rcdspayments As DAO.Recordset
Set rcdsSubsDue = db.OpenRecordset("qrySubsDue")
Set rcdspayments = db.OpenRecordset("tblPayments")

If txtDate = Empty Then
MsgBox "You must enter a date for this to work"
Exit Sub
End If

rcdsSubsDue.MoveFirst
Do Until rcdsSubsDue.EOF
rcdspayments.AddNew
rcdspayments("member ID") = rcdsSubsDue("member ID")
If rcdsSubsDue("status") = "J" Then Amount = 100 Else Amount = 300
rcdspayments("Amount") = Amount
rcdspayments("Date Due") = txtDate
rcdspayments.Update



rcdsSubsDue.MoveNext
Loop
End Sub
 
need one more piece of help ive tried various bits of code but can not seem to get it right.
I need to set a validation rule so when something in the wrong format is entered a message box comes up saying this is in the worng format.
Any tips?
 
Back
Top Bottom