Append Query - Turn off Warnings? (1 Viewer)

blueboy2001

Registered User.
Local time
Today, 07:20
Joined
Apr 22, 2002
Messages
26
I'm building a job scheduling database and I'm having a little trouble getting one of the input forms to work as I would like.

The basic idea is that customers book jobs, and I need to be able to assign multiple pieces of equipment and multiple workers to each job. Job table holds all the dates,times,customer details, etc about the job, and then tbljobequipment and tbljobdrivers are my tables to hold the drivers and equipment - they are simple 2 field tables holding jobid and equipmentid (or driverid).

I want the user to be able to select equipment from a drop down list and click a button to add it to the job. As I want multiple entries that rules out a simple bound combo, so I've unbound the combo and set up an append query. It works, but it throws up 2 warning boxes every time its run that will surely scare my users off! Is there any way to turn these off?

Secondly, if a user tries to add a piece of equipment to a job thats already there, it gives a key violation error (which is quite right). Is there any way I can customise the key violation error message to something more meaningful to the user? Thinking about it, perhaps it would be best if I tried a bit of validation code before the append query was run to prevent the message in the first place?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 02:20
Joined
Feb 19, 2002
Messages
43,263
I want the user to be able to select equipment from a drop down list and click a button to add it to the job. As I want multiple entries that rules out a simple bound combo, so I've unbound the combo and set up an append query. It works, but it throws up 2 warning boxes every time its run that will surely scare my users off! Is there any way to turn these off?
- rather than doing this with code, it would be easier to simply use a subform.

To turn off errors, you can set warnings to false prior to running a query and then set warnings to true immediately after running the query. It is imperative that you remember to turn the warnings back on. Leaving warnings off will prevent Access from warning you that there are unsaved changes should you modify something and forget to save it. With warnings on, Access will ask you if you want to save. With warnings off, Access will simply discard the changes without asking.

DoCmd.Hourglass True
DoCmd.SetWarnings False
....
DoCmd.SetWarnings True
DoCmd.Hourglass False


I strongly suggest setting the hourglass on whenever you turn warnings off. Should you sometime forget to turn warnings back on, the hourglass is a visual reminder that they are off.
 

Users who are viewing this thread

Top Bottom