Results 1 to 2 of 2
Thread: Help with Controls in a Form
11-06-12, 18:23 #1Registered User
- Join Date
- Oct 2012
Help with Controls in a Form
I was wondering if someone could help me with a problem I am having with controls within a form. Currently I have the form set up with a record source of Table1. My controls within the form are controlled by specific fields in Table1. The forms purpose is to have users enter in values to theses controls (text boxes and combo boxes) and to click a command button "Add Adjustment" which would then add a new record to table 1. Currently, with the Macro I have set up, this works fine.
However, if a user were to enter in a value into any one of the controls within the form and then were to close the form, or even delete the value within the control, and then were to go to Table1, a new record would have been created. I would like to make sure this doesn't happen, but I am not sure how to stop it from doing so when the Control Sources for each control is linked to Table1. If I change the control source, then I am not sure how to add a new record to the table by having users input data into the control fields.
11-06-12, 23:14 #2Registered User
- Join Date
- May 2004
- New York State
You can always have a routine, or do it manually, to remove all blank or semi-blank records.
However, that would only be half an answer. The truth is that this is a common problem, and this is the way it's done in other dbs I've used. Simply don't have the values saved in a new record automatically; have a command button to force the issue.
1) Remove the table from the RecordSource property, and leave the property blank.
2) Use your Add Adjustment command button to save the record. In the cb's OnClick event, comment out the current code relating to saving the record, open the table as a dbOpenTable, execute an .addnew method, map the form's controls to the appropriate db fields, execute an .update method, and you're done. Close the table. Also, blank out the form's fields to get it ready for the next record.