Starwood said:
I plan to write some VBA code for a command button on an Input Form. Can
anyone help with answers to the following questions:
1) In VBA, how do you reference the values (field names) of the fields in
the previous Input Form that was displayed?
are you saying that the current form was called (opened) by the previous
form?
Sure, just declare a variable in the current form (module level)
dim frmPrevous as form
Now, in your on-load event, or on-open event, go:
set frmPrevous = screen.ActiveForm
(activeform does not change until the on-open, and on-load is complete..so,
at this point in time, activeForm is the previous calling form).
2) In VBA, how do you reference the values (field names) of the fields in
the Input Form that is currently displayed?
simply go:
me.NameOfContorlOnform
or
me!FieldName (if the control is not on the form)
The above is for code *in* the current form. If you need to reference field
values in another open form, then you can go
forms!NameOfForm!NameOfField
3) Are the field values from the previously displayed Input Form stored in
a
named buffer? If so, what is the VBA buffer name?
Do you mean previous form, or pervious record? (that is a GRAND CANYON OF A
DIFFERENT ISSUE!!!).
Or, do you mean the current record, and can we reference "old" values, and
updated (edited/changed) values?
For previous form, as mentioned, just reference the form name, or setup a
variable as per my example.
if you talking about previous record...no, there is not such a thing...
If you talking about previous values for the current record we are editing,
then yes, you can go:
me.NameOfContorl.OldValue
4) Are the field values of the current Input Form stored in a named
buffer?
If so, what is the VBA buffer name?
There is no buffer, but all of the controls and values can be referenced,
and they not been committed to the table (or query) until the users moves to
another record, closes the form etc.. You can also force a disk write of the
current data (edited) values by going:
if me.Dirty = True then
' changes have been made...write to disk
me.dirty = false
end if
So, if any editing has occurred, the me.Dirty property will be true. And, if
any editing has occurred, the forms before update event will fire before the
disk write. (this means you rarely have to use me.dirty to check if things
been changed, since any code in the before update event will not run if no
changes to the form been made.).
Normally, you don't need the above code to force a disk write, since moving
to a new record, closing the form etc will write out the data for you.