Edit Record Form

WackyWaterGuy

Registered User.
Local time
Yesterday, 23:20
Joined
May 29, 2003
Messages
25
Hi there. I am currently working on a form to bring up data based on a work request number (each entry has a unique work request number). I have set everything up so that they can enter the data with no problem.

I have a second form designed in such a way that they can recall this data based on the work request number and edit some aspects of it (for example, when they first enter the info, it is assumed that the work has not been completed yet. They are able to go in once with work has been completed, and change that particular field). I have this form working correctly as well.

Everything works just as I want it to when they enter a valid work request number (ie, one that is in the table). However, if they enter an invalid work request number (ie, there is no matching work request number already entered) then it just brings up a blank form.

What i would like to be able to do is have a message box display saying something like "invalid work request number entered" when an invalid number is entered, instead of opening the form with all the fields blank.

Does anyone have any suggestions on how I can prevent the blank form from being displayed (ie, somehow verify that the work request number entered on the edit form is a valid one already in the table??)

Any help would really be appreciated.

Thanx
 
This can be easily done using DLookup. You would want to put code something like this in the Before Update Event of your textbox.

Code:
If Nz(DLookup("WorkReqNum", "MyTable", "WorkReqNum = " & Me.txtWorkReqNum)) = "" Then
     MsgBox "Invalid Work Request Number"
     Cancel = True
End If

You can find a decent explanation of DLookup in the Access Help files.
 
Thanks alot. I was thinking that I had to do something with DLookup, but just didnt know how to put it together!

I appreciate the help!

Thanks a bunch
 

Users who are viewing this thread

Back
Top Bottom