I'm not able to do what I want using the pure Access Way (if I
understand it correctly as letting access control the appearance
of New rows, letting deletes be controlled by the left "button"
etc.). Mixing bound forms and program control is making me nuts.
Then you're not doing it right -- you're making it too complicated.
I'm going to try a completely unbound
form. What is your favorite way to load the fields in the form as
you get records in your recordset?
Start out with your form bound. Drop all the controls on the form.
This will create controls with the names of the fields they are
bound to. Remove the ControlSource of each of the controls, and the
form's Recordsource.
To load data, you open a recordset on the former Recordsource
(though filterd to a single record, of course, and do this:
Dim rs As DAO.Recordset
Dim ctl As Control
Set rs = CurrentDB.OpenRecordset("[your former recordsource]")
rs.MoveFirst
For Each ctl in Me.Controls
ctl = rs(ctl.Name)
Next ctl
Set ctl = Nothing
rs.Close
Set rs = Nothing
Since the controls have the names of the fields they were formerly
bound to, this will load the data very easily.
Now, it can't be quite that simple, as you very often have controls
on your form that are not for editing the data (such as command
buttons), but that's easily handled in a number of ways. My
preferred approach is to set up a custom collection including only
the fields that will have data loaded from the recordset that I
populate in the form's OnOpen event. It's much more efficient than
testing for a .Tag or testing ControlType each time you load/save
data.
Now, for saving data, you reverse the process:
rs.Edit
For Each ctl in Me.Controls
rs(ctl.Name) = ctl.Value
Next ctl
rs.Update
You may, if you're cautious like me, choose to test whether the
values differ before assigning the value. I do that because I have a
lot of replicated applications, and I don't want to change fields
whose actual data is the same (this can result in unnecessary
conflicts, even with field-level conflict resolution, as is the norm
in Jet 4).
But if you do all of this, you lose much, much more than you gain.
You'll have to program every single behavior, including navigation
and all the data-based events (there's no .Dirty property in an
unbound form, for instance, and thus, no OnDirty event, just to name
one of the most important losses).
From what I've seen you have attempted to program all sorts of
things that I would never write a single line of code for, and each
time you've chosen the least appropriate method for programming what
you're trying to do. I think you'd be much better served by trying
to do things the easy way, rather than going unbound and losing all
the advantages of Access.
Put another way, if you're going to go unbound for all your data
editing, there's really no point in using Access in the first place,
as you'll now be on par with programming environments that don't
have all the RAD tools that come in Access from using bound forms.