J
JohnH
I've designed a "ledger" form that generally acts like a datasheet
form, but uses text boxes, comboboxes, and a lot of code to act in a
much prettier way.
I first attempted to link the form to appropriate records (from 1
table) by setting the form's recordsource at runtime to a query string
and then using event driven procedures to create new records, update
records, and delete records (represented by line items in the ledger)
in the form's recordset (the controls in my ledger remaining unbound,
only the form is bound). This was leading to problems I wasn't sure
how to solve, such as retreiving field values from the form's
recordset, which doesn't seem to work the same way it does if you bind
a form at design-time, where you can reference fields by name even
when no control exists on the form for that field.
If the above is confusing, I'll put it in other words:
I was binding the form at runtime only so I would have a recordset I
could use to perform actions on based on the unbound controls in my
ledger and the code I've written that determines when a new line item
has been created, when a field in a line item has been edited, etc..
(I could have just created a recordset object (and maybe should have,
or should) but I was using the form's for visual debugging purposes.)
My questions are:
1) What would you recommend: That I use a) this approach, or b)run
Append, Update, and Delete queries for all necessary actions and
forget form binding.
If...
a)
then
How would I accomplish something like retreiving the autonumber
primary key for a new record when
I've ...DoCmd.GoToRecord , ,acNewRec...?
If
b)
then
How would I accomplish the above in this situation? If I run an
Append query (for a single record), how do I then find out what unique
record I've just created (the autonumber PK)?
I appreciate any advice I can get.
form, but uses text boxes, comboboxes, and a lot of code to act in a
much prettier way.
I first attempted to link the form to appropriate records (from 1
table) by setting the form's recordsource at runtime to a query string
and then using event driven procedures to create new records, update
records, and delete records (represented by line items in the ledger)
in the form's recordset (the controls in my ledger remaining unbound,
only the form is bound). This was leading to problems I wasn't sure
how to solve, such as retreiving field values from the form's
recordset, which doesn't seem to work the same way it does if you bind
a form at design-time, where you can reference fields by name even
when no control exists on the form for that field.
If the above is confusing, I'll put it in other words:
I was binding the form at runtime only so I would have a recordset I
could use to perform actions on based on the unbound controls in my
ledger and the code I've written that determines when a new line item
has been created, when a field in a line item has been edited, etc..
(I could have just created a recordset object (and maybe should have,
or should) but I was using the form's for visual debugging purposes.)
My questions are:
1) What would you recommend: That I use a) this approach, or b)run
Append, Update, and Delete queries for all necessary actions and
forget form binding.
If...
a)
then
How would I accomplish something like retreiving the autonumber
primary key for a new record when
I've ...DoCmd.GoToRecord , ,acNewRec...?
If
b)
then
How would I accomplish the above in this situation? If I run an
Append query (for a single record), how do I then find out what unique
record I've just created (the autonumber PK)?
I appreciate any advice I can get.