Forum Discussion
AmberH675
Sep 09, 2024Copper Contributor
Update combobox and subform after new record added
Hello, I'm having two separate issues with updating a form/subform. First, I have a combobox on my main form, that is populated with client names. I have a button on this form, that opens a ...
AmberH675
Sep 09, 2024Copper Contributor
Thanks George,
For the command button - Thanks! It works.
Before, I was using the line DoCmd.GoToRecord , , acNewRec to start on a new record, but this no longer happens. Is there a way to have it open on a blank new record?
And for the sub form, that doesn't seem to work...
I have the following code when the 'add order' button is clicked:
DoCmd.OpenForm FormName:="frmHamperDt", view:=acNormal, windowmode:=acDialog, OpenArgs:=ClientID
And I have the following code on the subForm itself
Private Sub Form_Close()
Forms![frmClientHampers]![frmHampersSub].Requery
End Sub
Should I have that requery code somewhere else?
Thanks,
Amber
For the command button - Thanks! It works.
Before, I was using the line DoCmd.GoToRecord , , acNewRec to start on a new record, but this no longer happens. Is there a way to have it open on a blank new record?
And for the sub form, that doesn't seem to work...
I have the following code when the 'add order' button is clicked:
DoCmd.OpenForm FormName:="frmHamperDt", view:=acNormal, windowmode:=acDialog, OpenArgs:=ClientID
And I have the following code on the subForm itself
Private Sub Form_Close()
Forms![frmClientHampers]![frmHampersSub].Requery
End Sub
Should I have that requery code somewhere else?
Thanks,
Amber
George_Hepworth
Sep 09, 2024Silver Contributor
"... DoCmd.GoToRecord , , acNewRec to start on a new record,"
It depends on where that line of code is. As I noted, the code is suspended by opening the second form as a dialog, so this line will have to be in the second form, not the calling form. You could put it in the Open event of the second form.
Again, the requery should be in the calling code, i.e. the code which opens the Order form. Try this approach.
DoCmd.OpenForm FormName:="frmHamperDt", view:=acNormal, windowmode:=acDialog, OpenArgs:=ClientID
Me.[frmHampersSub].Form.Requery