Can somebody please help me with some coding.
I have designed a DB to hold all the invoices that my company recieves.
What i want to do is:
I found this code which I have tried to change for my needs but I’m afraid I’m in way over my head with this one.
Private Sub SearchInvoice_AfterUpdate()
On Error GoTo SearchInvoice_Err
With CodeContextObject
DoCmd.GoToControl "[InvoiceNo]"
DoCmd.FindRecord SearchInvoice, acEntire, False, , False, acCurrent, True
Me.InvoiceNo.SetFocus
End With
If Me.InvoiceNo <> Me.SearchInvoice Then
If Msgbox ("No matching records found. Would you like to create a new record for this project?",vbyesno, "Notice!") = vbYes Then
Docmd.gotorecord, , acNewRec
Me.BrokerName.SetFocus
Else
Me.SearchInvoice.SetFocus
me.SearchInvoice.value=Null
End If
End If
SearchInvoice_Exit:
Exit Sub
SearchInvoice_Err:
Exit Sub
End Sub
The only thing that happens after an update in the searchInvoice field is the focus goes to the invoiceNo
Any help would be greatly appreciated.
Thanks
I have designed a DB to hold all the invoices that my company recieves.
What i want to do is:
- Have the user input a new invoice number into an unbound textbox.
- Have the DB search for any matching records.
- If matching records are found have a msgbox open with two options for the user. A. View this record on the current form B. Return to the current form to enter a new invoice number
I found this code which I have tried to change for my needs but I’m afraid I’m in way over my head with this one.
Private Sub SearchInvoice_AfterUpdate()
On Error GoTo SearchInvoice_Err
With CodeContextObject
DoCmd.GoToControl "[InvoiceNo]"
DoCmd.FindRecord SearchInvoice, acEntire, False, , False, acCurrent, True
Me.InvoiceNo.SetFocus
End With
If Me.InvoiceNo <> Me.SearchInvoice Then
If Msgbox ("No matching records found. Would you like to create a new record for this project?",vbyesno, "Notice!") = vbYes Then
Docmd.gotorecord, , acNewRec
Me.BrokerName.SetFocus
Else
Me.SearchInvoice.SetFocus
me.SearchInvoice.value=Null
End If
End If
SearchInvoice_Exit:
Exit Sub
SearchInvoice_Err:
Exit Sub
End Sub
The only thing that happens after an update in the searchInvoice field is the focus goes to the invoiceNo
Any help would be greatly appreciated.
Thanks

Last edited: