I can't use a toggle button to open a subform

damienjude

Registered User.
Local time
Tomorrow, 01:06
Joined
Oct 30, 2012
Messages
11
I am very new to MS Access and I used Form Wizard to make a Linked Form
The tables are Events and Photos, the joined fields are Events!ID to Photos!EventID

perhaps its the module to the link which is


Sub Form_Current()
On Error GoTo Form_Current_Err

If ChildFormIsOpen() Then FilterChildForm

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit

End Sub
Sub ToggleLink_Click()
On Error GoTo ToggleLink_Click_Err

If ChildFormIsOpen() Then
CloseChildForm
Else
OpenChildForm
FilterChildForm
End If

ToggleLink_Click_Exit:
Exit Sub

ToggleLink_Click_Err:
MsgBox Error$
Resume ToggleLink_Click_Exit

End Sub
Private Sub FilterChildForm()

If Me.NewRecord Then
Forms![Photo].DataEntry = True
Else
Forms![Photo].Filter = "[Event ID] = " & Me.[ID]
Forms![Photo].FilterOn = True
End If

End Sub
Private Sub OpenChildForm()

DoCmd.OpenForm "Photo"
If Not Me.[ToggleLink] Then Me![ToggleLink] = True

End Sub
Private Sub CloseChildForm()

DoCmd.Close acForm, "Photo"
If Me![ToggleLink] Then Me![ToggleLink] = False

End Sub
Private Function ChildFormIsOpen()

ChildFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "Photo") And acObjStateOpen) <> False

End Function




All in all I cant fathom what is being said, pls help
 
Can you post a copy of your database -remove anything private/confidential - as a zip file?
 
Are you trying to achieve what is the attached database?

If so, you might want to try toggling the SourceObject property of the subform between nothing and yourPhotoFormName, as in the example.

I've included comments in the code to explain what's happening.

I hope it's useful in giving you a start.
 

Attachments

The files in the attached Zip file need to be extracted into C:\Event01 to work properly.

I've added a bit about hyperlinked files into it.
 

Attachments

Users who are viewing this thread

Back
Top Bottom