Dynamic forms..?

  • Thread starter Thread starter Lyndon
  • Start date Start date
L

Lyndon

Hi all,

I've encountered a problem with an application I am developing in
Access. I have a series of tables that appear in a listbox on the left
hand side of my form. In the right hand side I have a subform showing
the contents of each table in a datasheet when the user clicks on a
table from the left hand side listbox. The user is then free to make
changes to the data in each table, which uses the underlying input
masks and field validation when I developed the tables.

I want to incoroprate an audit trail into my system to record changes
made to the tables. In a separate project have developed code using
the BeforeUpdate event to capture changes made to fields in a form and
store them in a table. This works fine but combining the two is where
the problem lies.

When the SourceObject of a subform is an existing form, the form has
the BeforeUpdate event available and I can bind the audti trail code to
this event. However, in my application I am binding my subform to a
table based on the users selection. When a table is bound to a
subform, the BeforeUpdate event (and most others) are not available and
I cannot implement the audit trail as I would like. The problem is
either how to trigger a BeforeUpdate event for a table bound to a
subform or how to dynamically populate a form with all the fields from
a table. If I do that, I can create one form and every time the user
selects a table I can populate the form with all the fields (in
datasheet view) and then the BeforeUpdate event will work. I can run a
select statement to return all the fields but how do I then add each
field to the form..? Or if there is a cleaner way to achieve this
audit trail on a table, what is it..?

Thanks in advance,
Lyndon.
 
Use the BeforeUpdate event of the form being used as the subform, not the
parent form.
 
Thanks for the reply...

I have already tried using the BeforeUpdate event of the form being
used as the subform, the problem is in my code I change the
SourceObject of the subform to a table when the user selects a table in
my application. When this occurs, the form that was the subform (with
the BeforeUpdate event) is no longer the subform, it's now a table to
allow the users to edit the contents. As there is no BeforeUpdate
event available to tables this approach doesn't work. Any other
ideas..?
 
Don't use a table as the source object: use a form instead. You should never
be working directly with tables anyhow.
 
Back
Top