Coding

  • Thread starter abdul wahab via AccessMonster.com
  • Start date
A

abdul wahab via AccessMonster.com

i have the following code in one of my forms, but dont know what it means.
pls can anyone give me a clue.


Private 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![FrmInvoice].DataEntry = True
Else
Forms![FrmInvoice].Filter = "[Car ID] = " & Me.[Car ID]
Forms![FrmInvoice].FilterOn = True
End If

End Sub
Private Sub OpenChildForm()

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

End Sub
Private Sub CloseChildForm()

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

End Sub
Private Function ChildFormIsOpen()

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

End Function
 
G

G. Vaught

Check to see if the Child form (related to Parent form) is open, if it is
close it by calling the CloseChildForm method. If the Child form is already
closed Open it by calling the OpenChildForm method and filter the form by
calling the FilterChildForm method. If there are any errors execute the
ToggleLink error otherwise Exit ToggleLink_Click Sub routine.

If you are adding a new record to the form, then set the data entry value to
true (same as Yes). Else if you are looking for an existing record filter
the form to the specified CarID entered and set the filter to true.

The last Sub returns the state of the child form. Either closed or open and
then sets that value to ChildFormIsOpen as long as it is not equal (<>) to
False.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top