Msgbox alert for existing records

M

mel

I would be very grateful if someone could please clarify the instructions to
my event procedure: I am entering travel reservations into a form and need
to be alerted if the "booking number already exists" and "ok to amend?" so i
want to go to that record to update it, or not "cancel" go to blank/new
record.... this is all i have got!
bngnmbr is the name of the column
bookings is the name of the form

Private Sub bkngnmbr_BeforeUpdate(Cancel As Integer)
Dim iAns As Integer
If IsNullDLookup("[bkngnmbr]", "bookings", "[bkngnmbr] = " & Me.bkngnmbr) Then
iAns = Msgbox("bkng number exists, OK to amend?,& vbCrLf & ") goto"

thanks!
 
D

David C. Holley

In the Form_Open event, the form automatically moves to a new record.
The txtGotoRecord_AfterUpdate is tied to control named [txtGotoRecord].
When a value is entered into that field, the form automatically filters
the form for the value. If none is found, it ends on a new record. This
should work for your purposes, *as long as you open the form will all
records from the underlying table*.

Private Sub Form_Open(Cancel As Integer)

DoCmd.GoToRecord acDataForm, "frmReservations",acNewRec

End Sub

Private Sub txtGotoRecord_AfterUpdate()

Me.FilterOn = False
Me.Filter = "lngTransportId = " &
[Forms]![frmReservations]![txtGotoRecord]
Me.FilterOn = True

'May want to put some code here to provide a MsgBox that the record
wasn't found.

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