I have similar situation with this link: MS Access automatically fill id in main form when data is entered in subform
In short, I wanted to be able to create autonumber ID in the main form when I enter data in subform. This is possible with this code inside sub form:
Private Sub Form_Dirty(Cancel As Integer)
With Me.Parent
If IsNull(!MainFormID) Then
' Change any field to create the parent record
.Description = "Test"
' Save changes on the parent form.
.Dirty = False
End If
End With
End Sub
I have pasted the VBA Code and create additional field called "Description" which capture changes in the main form. This works if I fill in a text box in subform. However, if I select an item from combobox it doesn't work.
Lets say my combobox is cboSelectItem, I also have tried changing the event to below but to no available.
Private Sub cboSelectItem_BeforeUpdate(Cancel As Integer)
Anyway to change the code to be able to run for combo box and still retain my selection from the drop down?
Sub Form_Dirty
a procedure in the sub form? How it is called? Where does the Cbx you mention come in? I'm not familiar withIsNull(!MainFormID)
syntax. So, I would question the use of the exclamation point. Your syntax for addressingDescription
andDirty
fields inMe.Parent
looks odd to me. If these are TextBoxes I would expect to set the Value or Text properties. If they are labels the default might be Caption.Dirty
could be a checkbox. I think you should specify the properties you mean. But no, sorry, I don't think I am qualified to assist with VBA for Access. – Variatus