Refresh Subform on closure of add entry form (1 Viewer)

zebra

Registered User.
Local time
Today, 10:41
Joined
Apr 23, 2009
Messages
20
Hi, I see hundreds of people have asked questions similar to this but I've spent all morning trying to copy theirs but I'm still stuck.

I have a mainform. In it there is a subform which displays a table. To add an entry to the table there is a 'create' command on the main form. The 'create' command brings up a form to add entries to the table. What I need is that when you close the add entry form, the table on the main form refreshes to show the new entry.

The names of all the forms (without the ' marks ;)) are:
main form = 'View Series List'
table = 'Series List'
subform that shows table = 'Series List subform'
add form = 'Add Series'

I think I need to change the code to close the add entry form. The code currently is:

Private Sub CloseAddnewSeries_Click()
On Error GoTo Err_CloseAddnewSeries_Click

DoCmd.Close

Exit_CloseAddnewSeries_Click:
Exit Sub
Err_CloseAddnewSeries_Click:
MsgBox Err.Description
Resume Exit_CloseAddnewSeries_Click

End Sub


really really appreciate your help- I'm also in a rush to do this for my boss!
 

Dennisk

AWF VIP
Local time
Today, 10:41
Joined
Jul 22, 2004
Messages
1,649
If you open the add form the main form via a button, open it as a dialog form, then in the line after the form open use something like the following me.subformname.Requery. or use the full qualifyier i.e. Forms!YourMainForm!YourSubForm.Requery.

Here is a link to referring to subforms http://www.mvps.org/access/forms/frm0031.htm
 

zebra

Registered User.
Local time
Today, 10:41
Joined
Apr 23, 2009
Messages
20
Hi Dennisk, sorry, I'm a beginner. I tried to put the full qualifyier in to the code to save the addentry form but when i run it it keeps saying: Microsoft Office Access can't find the field 'Basesubform1' refered to in your expression.

What exactly should I be writing?

Thanks!!
 

WIS

Registered User.
Local time
Today, 19:41
Joined
Jan 22, 2005
Messages
170
Hi Dennisk, sorry, I'm a beginner. I tried to put the full qualifyier in to the code to save the addentry form but when i run it it keeps saying: Microsoft Office Access can't find the field 'Basesubform1' refered to in your expression.

What exactly should I be writing?

Thanks!!

Series List subform

When creating any objects in Access eg frms, qrys - don't put in any spaces. If (when) you have to use VBA code it causes hassles.
 
Last edited:

zebra

Registered User.
Local time
Today, 10:41
Joined
Apr 23, 2009
Messages
20
Right, thanks.
I've made a mock one up to make things easier.
The forms are called
table = 'Base'
main form = 'Mainform'
subform that shows table = 'Tablesubform'
add form = 'Addentryform'
In terms of command buttons I have an Open form called OpenAEform.
Private Sub OpenAEform_Click()
On Error GoTo Err_OpenAEform_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Addentryform"
DoCmd.Openform stDocName, , , stLinkCriteria
Exit_OpenAEform_Click:
Exit Sub
Err_OpenAEform_Click:
MsgBox Err.Description
Resume Exit_OpenAEform_Click

End Sub

And on the Addentryform a Save button:
Private Sub Saverecord_Click()
On Error GoTo Err_Saverecord_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_Saverecord_Click:
Exit Sub
Err_Saverecord_Click:
MsgBox Err.Description
Resume Exit_Saverecord_Click

End Sub

and a close button:
Private Sub Closeform_Click()
On Error GoTo Err_Closeform_Click

DoCmd.Close
Exit_Closeform_Click:
Exit Sub
Err_Closeform_Click:
MsgBox Err.Description
Resume Exit_Closeform_Click

End Sub

That's it. Thanks again!
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:41
Joined
Sep 12, 2006
Messages
15,651
basically what you need to do is this

1. open popupform
2. WAIT FOR POPUPFORM to close
3. requery data

to do step 2, you either need to
a) open the popup form in dialog view or
b) have extra code to wait for it to close (i often do this, as i dont really like dialogs in general)
 

zebra

Registered User.
Local time
Today, 10:41
Joined
Apr 23, 2009
Messages
20
Thanks gemma, ok how do you open the popup in dialog view or what is the extra code I need to write?
Cheers.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:41
Joined
Sep 12, 2006
Messages
15,651
docmd.openform .....

one of the options at the end will be acdialog - thats the one you want.

or just design the popup form as a dialog form.

its one of the window/border style properties
 

zebra

Registered User.
Local time
Today, 10:41
Joined
Apr 23, 2009
Messages
20
Right, er ok, I have changed the border property to Dialog. Now what do I do? : D


ps. sorry for getting your gender wrong!
 

Users who are viewing this thread

Top Bottom