Display a message when the wrong Contract is input

Stemdriller

Registered User.
Local time
Today, 05:30
Joined
May 29, 2008
Messages
187
My first live, online database is about to go live.

The query asks the user for a 'Contract Number' which they enter and the form the displays the Contract details, which it obtains from an imported table. But if they input an incorrect contract number it just displays a blank form and I would like it to display an error message, asking them to re-enter a valid contract number.:confused:

Any help would be appreciated.
 
try this sort of thing -

contractno = nz(dlookup("contractno","tblcontracts","contractref = " & yourinput),0)

if contractno = 0 then
msgbox("No such contract")
exit sub
end if
 
Last edited:
I would use a combo box set to limit to list based on the contract numbers. This prevents users from selecting an invalid number. More user friendly than an error dialog.
 
Combo Box is an alternative but there are over 4000 contracts.

Gemma - the field name in the table is SALESORDER the table is called Ctcts
on your response you put "contractre f"????? Is this an error?

I understand what you are saying however. Lookup the field called 'SALESORDER' in table 'Ctcts' if no match return 0.

I have tried putting this routine 'Before the Event' too. But I get 'Compile Error' - Invalid Outside Procedure.
 
You don't have to pick from a combo, you just type your number and it 'zooms' to the record you're typing.
 
i just gave an example of what the code ought to look like
change it to match your circumstances

the space in contractref appeared magically - i couldnt seem to edit it out (and still can't - i just tried again!)
 
No, Bob, the site is playing up today. I've had the same problem.

It's ALWAYS had that problem. It isn't just today. Use the code tags and it won't do it. I'm serious.
 

Users who are viewing this thread

Back
Top Bottom