updating subform (1 Viewer)

Massoud

Registered User.
Local time
Today, 04:09
Joined
Jul 11, 2002
Messages
37
Hi

To add new records in the subform, I use a dialog box. after submitting the data the subform doesn't update.
I have to close the main form and re-open it again and then I can see the new record.
I have the same problem with combo boxes. At some conditions it is needed to open dialog boxes to add new records. but then again the main form should be closed and reopened to be able to see the new records.
 

rsmonkey

Registered User.
Local time
Yesterday, 20:09
Joined
Aug 14, 2006
Messages
298
use the Requery function refreshes the data without having to open/close a form. i.e say we are dealing with combo boxes then something like this:

Code:
Private Sub Combo1_AfterUpdate()

Combo2.Requery

End Sub

etc.. you get the idea use it in the form load or where'ever its hard to tell you exactly where without see'ing your db but hopefully you get wat im saying
 

Massoud

Registered User.
Local time
Today, 04:09
Joined
Jul 11, 2002
Messages
37
This is my my code
Private Sub bt_moincreate_Click()
DoCmd.OpenForm "account_new", , , , , , OpenArgs:=Me.kol & "~~" & Me.kol_code
Me.accounts_moin_sub.Form.Requery
End Sub

account_new form inserts the data in the table.( the query line works well) but the accounts_moin_sub form doesn't update after the code is done. I've also tried:
Me.Requery
or
Me.accounts_moin_sub.Form.Requery

but no results
 

boblarson

Smeghead
Local time
Yesterday, 20:09
Joined
Jan 12, 2001
Messages
32,059
This is my my code
Private Sub bt_moincreate_Click()
DoCmd.OpenForm "account_new", , , , , , OpenArgs:=Me.kol & "~~" & Me.kol_code
Me.accounts_moin_sub.Form.Requery
End Sub

account_new form inserts the data in the table.( the query line works well) but the accounts_moin_sub form doesn't update after the code is done. I've also tried:
Me.Requery
or
Me.accounts_moin_sub.Form.Requery

but no results

In the close event of your new account form put:
Code:
Forms!YourMainformNameHere.YourSubformCONTAINERNameHere.Form.Requery
Subform container is the control housing the subform on the main form. You can't use the ME keyword as it doesn't refer to the form it is on and also you can't use the code you've been doing since it is going to happen before you update the other form UNLESS you set the new account form to open as a dialog.
 

Users who are viewing this thread

Top Bottom