Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best Practices for associating an UNBOUND form to a recordset

Status
Not open for further replies.

Jeffr0

Programmer
Mar 4, 2010
8
US
Hello,

I'd appreciate any hindsight or techniques for some of the housekeeping necessary for keeping an unbounded form in sync with a recordset.

I am working on an app to allow data entry of the responses to a particular survey. (the survey and its underlying representation of questions and answers precludes my use of a bounded form, as discussed on this thread.)


For example:

* User wants to enter new set of responses from a survey
-- Create a new responses recordset
-- Use placeholder NULL values for all of the recordset fields.
-- Sync the form UI control values to the (blank) recordset. I.e., blank form.

* User enters in a value into a form UI control (text field or checkbox, say)
-- Need to sync this change to the recordset once user leaves this field
-- So, handle all control focus change events (??)
-- When a focus change event occurs, call a form-global function that syncs all of the form UI control values to the recordset. (or, pass the ID of the control and sync only that value? more efficient)

* User wants to exit midway through form entry for lunch break
-- User hits Ctrl-S to save, or clicks 'Save' button, or closes form, etc
-- Sync form UI control values into recordset; update recordset into db
-- Optionally exit application if user has closed form

* User wants to edit an existing response set (they get back from lunch and re-launch Access)
-- Query recordset out of database tables
-- Sync form UI control values to the values in the recordset
-- Not-yet-entered values will be NULL in recordset. Corresponding controls are therefore in an unset / empty state.


From this analysis, it seems like the main subroutines would be:

Sync All Form UI Controls To Recordset
Helper function: Sync a specific UI control to a Recordset
(big Switch statement?)

Sync All Recordset To Form UI Controls
Helper function: Sync a specific UI control to Recordset
(big Switch statement?)

Create new, blank recordset
Update database with recordset
Close/Open database

Does this sound like a sane approach? Are there any gotchas I should be aware of here? And, any examples of existing code would be great as well. I'll post follow-up on my progress.

Thanks,
-Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top