Reputation: 4753
I have a MS Access form which displays list of records in grid . Each row is having a detail buttton.
When clicked on it , it opens up a new form with details of that particular selected row.
When click on close button of detail form , the values get saved to database.
Now , on click of close , i would like to execute Form Load of main form . This is because i need to refresh some values after update is made in detail form
I have tried some thing like this :
Call Forms!frm_Package!Form_Load
Please suggest on how to accomplish this . I have tried various ways but could not get it worked.
Please let me know if any further information is required.
Upvotes: 0
Views: 15176
Reputation: 1004
I use this code to do this kind of things. I hide the main form when i open a popup form ... i do my work and then i return to the main form.
Private Sub Form_Open(Cancel As Integer)
If gIsLoaded("mainForm") Then Form_mainForm.Visible = False
End Sub
Private Sub Form_Close()
' -- here you will put the code you need!!!
If gIsLoaded("mainForm") Then Form_mainForm.Visible = True
End Sub
Function gIsLoaded(strName As String, Optional _
lngtype As AcObjectType = acForm) As Boolean
gIsLoaded = (SysCmd(acSysCmdGetObjectState, _
lngtype, strName) <> 0)
End Function
Upvotes: 0
Reputation: 5809
The reason you could not "re-call
" the Load is because it is a Private Sub
and only when you are inside the Form you can access the method.
One way to hack "external procedure call" is to move the code inside the Form Load into a Public Sub (withing the same Form) and then calling the newly created Sub from outside the form. Like,
Private Sub Form_Load()
MsgBox "Hello World"
End Sub
TO
Private Sub Form_Load()
newPubMethod
End Sub
Public Sub newPubMethod()
MsgBox "Hello World"
End Sub
Now you will be able to call this Public Sub newPubMethod even from outside the Form with the right quantifiers.
Private Sub exitButtonName_Click()
Forms("CallingFormName").newPubMethod
End Sub
Upvotes: 1