I am using a form to create invoices ("frmInvoices"). Since people sometimes send prepayments for next month invoice, I record three fields; "Prepayment Amount", "Prepayment Month", "Prepayment Year" on "frmInvoices". I am looking to place this data on the 'tblPrapayment' table as well.
The kicker. For my system to work, I need to make sure that when the invoice form is saved and a prepayment value has been entered, that month and year are entered as well.
I have placed this code in my Microsoft Access Class Objects, not a module. I only need this to work on the "frmInvoices" form. I don't get any errors. But nothing really happens either. If you know an easier way to do this I am open to it as well.
Private Sub Add_Prepayment_Save()
DoCmd.Save ("frmInvoices")
If [Rec'd_Prepayment] = "$0.00" Then
DoCmd.Save ("frmInvoices")
End If
If [Rec'd_Prepayments] <> "$0.00" And [Prepayment_Month] = "" Or [Prepayment_Year] = "" Then
MsgBox "Please Update Prepayment Month And/Or Prepayment Year"
End If
If [Rec'd_Prepayments] <> "0.00" And [Prepayment_Month] <> "" Or [Prepayment_Year] <> "" Then
Dim RecSet As Recordset
Set RecSet = CurrentDb.OpenRecordset("tblPrePayments")
RecSet.AddNew
RecSet![AccountID] = "AccountID"
RecSet![Prepayment_Month] = "Billing_Month"
RecSet![Prepayment_Year] = "Billing_Year"
RecSet![Rec'd_Prepayment] = "Prepayment1"
RecSet.Update
End If
End Sub
DoCmd.Save
and step through the code one line at a time with F8. – HansUpAdd_Prepayment_Save()
... what is supposed to cause that code to be executed? – HansUpIf
criteria with multiple clauses. Suggest you use parenthesis to avoid unexpected order of processing for operators (And/Or). – Smandoli