How to clear the form?
Thank you for taking the time to report an issue.
What's wrong... Please write below.
The users select invoice number from a unbound field on the main form which loads applicable data in the subform. I put a clear button on the main form to clear the fields but it gives me errors about how I can't change the record because it would cause duplicates.
How do I clear the fields when the users exit the form without gettingerrors.
In short, the data will be displayed in form until you clear it with a button - (dataentry will be yes, till you press the clear button)
My reason for doing this - when I temporarily close the main form and return later, all data captured are deleted from the subform, and I then have to check what was the last data captured, before continuing with the next lot. This wastes time.
the main form is "StocktakeF"
the subform is called : "Fis_stocktakeSF"
I don't need to save any records as this form is used solely for reporting purposes.
Specifically the Undo doesn't undo the subforms, just the Main form. I also am not sure how to make my clear button, clear out all controls on all 3 forms.
I am trying to add a button that if they get confused willclear the for for them and they can start over.
I would like to program the "Clear" button to loop through the form or table and deselect (clear or reset) all checkboxes.
Private Sub cmdClearCombos_Click()
' Resets ALL combobox values in the current form to null.
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is ComboBox Then
ctl.Value = Null
I tried adding another IF/Then after that one to clear TextBox, got errors.
Then I tried to add an OR, such as "If typeof ctl is ComboBox or TextBox Then" this also didn't work, although it did still clear my combo boxes and didn't error.
If I delete each field to clear the screen, it also deletes it from the table. This also happens when I go to my search form.
How do I prevent this from occurring. If the screen automatically clears, it will also delete from the table ? In the search form, I have a clear search button that clears all the search values in the form header, but not the detail.
Again, if I clear the detail, will it delete the record from the table ? And how do I prevent the search form from being edited once data isdisplayed ?
I am almost there but these are minor quirks that I cannot figure out.
I have a command button programed to save the record and would like it to clear the highlights for me as well. What is the best way to accomplish this goal?