SteveDataMan
New member
- Local time
- Today, 04:37
- Joined
- Sep 17, 2013
- Messages
- 3
Hi there,
I would welcome some help! My subforms are randomly adding blank records and one subform I would like to stay blank repopulates with data, though not necessarily the most recently added record. Both of these seem to happen when I navigate to other main records in the database and then return to this page.
Using Access 2013, I have a large form with 10 pages. On one of the pages, I have two subforms. This is set up to gather many-to-one data. The top subform is my data entry form with three fields (two combo and a text) and a command button. The bottom subform is a datasheet displaying the three fields.
The two combo boxes are cascading, and they work great. The text box is there to collect additional info for each selection.
The command button works to 1) save the record, 2) requery both subforms in order to display the new data on the datasheet, 3) clear the combo and text boxes, and 4) set focus back to the initial combo box. It all works! But then when I leave that main record, the horror begins: blank records (from the "many" table) show up on the datasheet and the data entry fields do not stay blank.
As everything else seems straightforward, I suspect my problem is in the command button. I added this code to the OnClick for the command button:
I welcome any thoughts or suggestions.
thanks!
Steve
I would welcome some help! My subforms are randomly adding blank records and one subform I would like to stay blank repopulates with data, though not necessarily the most recently added record. Both of these seem to happen when I navigate to other main records in the database and then return to this page.
Using Access 2013, I have a large form with 10 pages. On one of the pages, I have two subforms. This is set up to gather many-to-one data. The top subform is my data entry form with three fields (two combo and a text) and a command button. The bottom subform is a datasheet displaying the three fields.
The two combo boxes are cascading, and they work great. The text box is there to collect additional info for each selection.
The command button works to 1) save the record, 2) requery both subforms in order to display the new data on the datasheet, 3) clear the combo and text boxes, and 4) set focus back to the initial combo box. It all works! But then when I leave that main record, the horror begins: blank records (from the "many" table) show up on the datasheet and the data entry fields do not stay blank.
As everything else seems straightforward, I suspect my problem is in the command button. I added this code to the OnClick for the command button:
Code:
Private Sub addMinistryItems_Click()
'save record
If Me.Dirty Then Me.Dirty = False
'requery both subforms
Forms![BCD MAIN 2013]!Child572.Form.Requery
Forms![BCD MAIN 2013]!Ministries1.Form.Requery
'clear the combo and text boxes
Me.cboAddMinCat = Null
Me.cboAddMinItem = Null
Me.Text544 = Null
'set focus back to cboAddMinCat
Me.cboAddMinCat.SetFocus
End Sub
thanks!
Steve