I and (lots of other programmers) don't have any problem with bound
Controls. In fact, I think the power of Access comes from bound Controls
as Access will do a lot of work on data retrieval, manipulations and
updating automatically using bound Forms / bound Controls. However, if
you are more comfortable with unbound Controls, you can use them also but
you will have to handle data retrieval, manipulations & updating by your
own code.
Don't get me wrong, bound controls are great. When they work well, they are
great time savers.
I've seen lots of examples where it might be much more robust to avoid them
at all costs.
For the purpose of this thread, the specific scenario I am trying to work
through seems to be one that might justify doing it the hard way. If
there's a way not to, by all means, I'd love to know. Let me use the
Northwind example to illustrate:
Orders form.
Go to a new record.
Select a customer in "Bill To:"
Don't enter any products whatsoever.
Now click or page up/down away from this new record.
You just created an order without a single item being ordered. Not
something you would want to allow a user to do.
You would think that one could use the form's BeforeUpdate even to validate
the order. This would be true if the form did not contain any subforms.
However, in the case of "Orders" the subform gets in the way.
Another example of this is that you can go into any one order with multiple
ordered items and delete every single item in the order. Again, if you
could use Form_BeforeUpdate() to validate without ambiguity this could be
policed very nicely.
If you put validation code in the form's BeforeUpdate even this code will
also run when the use clicks or tabs through into the subform. And, as far
as I have been able to determine, there is no way to distinguish a
Form-to-Form BeforeUpdate event from a Form-to-Subform BeforeUpdate event.
This distinction, I think, is important.
So, here's the task: Make the Nothwind "Orders" form solid enough not to
allow faulty/incomplete orders to be entered into the database. Where do
you place the code?
I am relatively new to Access but not new at all to programming (well over
20 years, everything from embedded/hardware/software using assembly, FORTH,
C, C++, VB, LISP, Verilog and others). I still remember hand-wiring my own
Intel 8080-based computers and writing the OS by hand, including disk
drivers for 8 inch floppies. Anyhow, the coding process isn't a problem
here.
It might just be that I haven't identified just what to hook into in Access
in order to make it do what I want. Given my current failure I to find "the
way", I am thinking that the only way to make a form like Northwind's
"Orders" behave as stated is to take over and use unbound controls for most,
if not all, of it.
For the sake of maintaining focus, I am not interested in exploring an
alternative mult-form approach to entereing orders. I think using the
Northwind "Orders" form as it stands, with the aim of making it fully
validate order entry pretty much narrows my current quest (and hours of
frustration).
I'll appreciate a shove in the right direction if there is one to follow.
Thanks for your help,
-Martin