Error message in subform

E

Eva Shanley

I have a subform that generates an Invoice Number
depending on certain conditions. If this is a new record
and the Line Number keyed in is a 1, then I need a new
Invoice Number. If this is the 2nd record on the subform
and the Line Number is a 2, then give me the same Invoice
Number. The code attached to the Line Number seems to be
working properly, but if I click the New Record button and
I'm in the Invoice Number field in the subform, I get a
Run-time error '2424' - The expression you entered has a
field, control, or property name that Access can't find. I
don't pretend to know VB code very well, and I can't solve
this problem. TIA.

Sub LineNumber_LostFocus()

If Me.NewRecord And Me.[LineNumber] = 1 Then
Me![InvoiceNumber] = DMax("InvoiceNumber", "tbl Rents") + 1
Else
If Me.NewRecord And Me.[LineNumber] > 1 Then
Me![InvoiceNumber] = DMax("InvoiceNumber", "tbl Rents")
End If
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top