Help I need Code

  • Thread starter Thread starter bobcuin
  • Start date Start date
B

bobcuin

Guest
Help - I need VBA code to update a record number on opening a new subform.
I have a button to open a new record within a main form but I need to update the included number of the item. EG imagine a PO with added items. The items need to be numbered consec to the PO. Can't use autonumber for this as I need this for indexing.
I have tried various things and got from 1 to 2 but then I hang on 2.
Any suggestions out there? Thanks:confused:
 
You could adapt this:

Public Sub NextInvoiceNo()
On Error Resume Next

If IsNull(DMax("InvoiceNo", "Invoice")) Then
Forms!F_Invoice!InvoiceNo = 1
Else
Forms!F_Invoice!InvoiceNo = DMax("InvoiceNo", "Invoice") + 1
End If

Forms!F_Invoice.Refresh
If Err = 3022 Then
Forms!F_Invoice!InvoiceNo = ""
Forms!F_Invoice.Refresh
NextInvoiceNo
End If

End Sub
 
Thanks

Thanks - I'll give this a try over the weekend...:cool:
 

Users who are viewing this thread

Back
Top Bottom