1. What's the difference between ! and . when refering to forms and fields
Well, as a generally rule, "." refers to built in ms-access collections and
methods (functions).
User defined objects, you supposed to use ! In theory, this would mean that
since YOU add controls to a form, then we should use a ! to reference
controls on a form.
However, when you place a control on a form, then it becomes part of the
forms properties collection, so you can use "."
And, using dot is easy, since you get that pop-up list (inteli-sense).
I as rule use "." for when I reference a control on a forms. If you do NOT
expect the control to be on the form, the I
use ! (bang) to work with the data. I do this, since then you can set/grab a
value from the underling reocrdset, but NOT have to place a control on the
form. However, ms-access does confuse this, since both ".", and "!" will
work to get at the underlying reocrdset EVEN IF YOU DO NOT place a control
on the form. (however, this ONLY works if you do NOT change the forms
reocrdset at runtime).
This means that the "." is resolved at compile time, and the "!" is resolved
at runtime!. This means you if you plan to change/set the reocrdsouce of a
form in code (ie:runtime), then you HAVE TO use "!", or place a control on
the form that is bound to the reocrdset, and use ".". (if the form is
un-bound...but will *eventually* have its data source set, then you can't
use "." in your code. (try it..the code will not compile). However, you can
use "!".
So, dot always works for controls...but not for when you want the data..but
no control. This being the case, then I use "dot" when I have the control
on the screen and use ! when I just using the data on the form..and don't
necessary have a control with the same name on the form.
Many a developers actually as a rule DO NOT use the same name for controls
on a the screen as the underlying data files. This totally eliminates the
confusing. I just think it is too much extra work, but I don't fault
developers to who take this extra precaution. This extra precaution (using
different names for the controls then that of the field name in the table)
means that NO confusing can occur in code when you refer to the control on
the form, or the data that the control uses.
2. I'm adding to a Company Expense Claim application and the continuous
form
is a line on the claim for business mileage, dinners etc.
A "classic" problem. You have a amount, and must disperse that amount to
several accounts. I think every developer eventually has to do this!!! It
would certainly be one of the things I would cover if I teacher this stuff!!
Note in my screen shots, the VERY last screen does exactly just that! It is
a donations screen. Note how I don't pop up another form, but use two
sub-forms side by side. In that example, it is a amount on the left side
($50), and on the right side you see a green box with the total (if they
don't match..it is red). And, note how two entries $20, and $30 add up to
the total of $50. Further, that screen is actually designed to use keyboard
entry from START TO FINISH...you do NOT have to use the mouse!!! The data
entry person can just enter one after another...really fast....
The simply solution I used here was don't verity the amount during data
entry!!! it makes it SOOOO simple
Note very close on that example screen shot (the last one), there is posting
button on the bottom of the screen. You enter all of your data, (in my
example, donations for the day), and then when done, press the post button.
The posting routine checks for the totals to match..and you CAN NOT close
that posting until they match!. Further, users do NOT have the ability to
un-post!!! So, I don't check during data entry!!!...users MUST post/close
the entries when they are done.
This just solves everything, and actually allows the user to enter
UN-FINISHED data...users love this!!
Further, they can work real fast..and check the results AFTER they work...
Further, once posted, then I disable editing of data. If you look close at
the top of the screen, it shows the current batch has been posted..and the
post time. Editing of that data is thus disabled...
So, if you matching up to totals on the left side, and right side becomes
too difficult to verify, then simply don't check during data entry. Just
have a final "close" button that checks this for you. and, simply requite
that all staff must "post/close" there entries when done. when reports are
generated, simply show the posting status.
And, the posting routine does not actually post any data, but just runs some
code to check the totals. If the totals are all ok..then he posting simply
changes the post status to "yes", puts in the post time..and we are done....