Record Navigation

  • Thread starter Thread starter Thomas Kroljic
  • Start date Start date
T

Thomas Kroljic

I have a simple form that is currently using Access' Navigation Buttons. Is
there an easy solution to the following: if the user decides to create a new
record, I would like to be able to valid that one of two fields are entered
on the form (contact name or company name) before moving to another record.
Can I some how tell Access to cancel the Navigation movement (next or
previous) if both fields on the form are blank (there are many fields on
this form, I just need to ensure that the user enters a contact name or
company name before moving on).

I've read several posting and some have suggested using a custom navigation
subform. But before I go that route, I thought I'd asked some folks.

Thank you,
Thomas J. Kroljic
 
Hi Thomas,
consider using the Form_BeforeUpdate() event to check for
values in these fields. If both are null the set cancel to
true. This will stop any navigation movement.

Private Sub Form_BeforeUpdate(Cancel)
if isnull(txtContactName) or isnull(txtCompanyName) then
msgbox "Some suitable expletive",vbexclamation,"Big
Brother is Watching for valid data entry"
cancel=true
End IF
End Sub

Luck
Jonathan
 
Jonathan,
Thanks for the code snipet...it works perfectly. I original had similiar
code, but I had it in the BeforeInsert event. Thanks for pointing me in the
right direction along with your example code.

Thomas J. Kroljic
 
Back
Top