PDA

View Full Version : DoCmd.OpenForm and DoCmd.OpenQuery issues



technocraze
02-11-2007, 10:17 AM
Hi community experts,

May I know is it possible to display an error message or not opening a form or query when users provide with the wrong inputs in the DoCmd.OpenForm and DoCmd.OpenQuery properties. If that is possible what must be done to achieve?

OBP
02-11-2007, 10:37 AM
How can a User supply the wrong Information?
The Form or Query Name should either be Hard Coded by the Programmer, this is the normal recommended method.
Or provide a List Box or Combo Box using the Database's form or query names, but with this method the Programmer will have more difficulty controlling filters etc.

Halldo
02-12-2007, 09:21 AM
Technocraze,

It is possible to leave it unbounded if you have a stringent set of business rules around what they can enter.

Or you can also compare their entry against the query and form definitions and if it does not match one of those, then pop a message box that indicates no match was found. This method is more accurate, however takes a little longer to run.

In either case, you can then use a simple if then else statement to perform the test and either pop a message box indicating there was no match or perform the Docmd.

I believe I have code that supports either one of these approaches let me know which way you would like to proceed and I will search for the proper code.

Halldo