Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Sub Form Issue

Im having a problem linking 2 subforms together. I have 4 forms being used,. the first decides the site or location its called Site, from tht form, it opens another form "new vendor" which scrolls through the vendor. The Vendor code determines which PO records will appear.

How this is working is that, when i choose the site, the vendor changes and the PO changes to the fist purchase order from that vendor. but if i scroll through the other vendors, the PO stays the same. Heres the Code for the New Vendor:

Option Compare Database

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![PO filter].DataEntry = True
Else
Forms![PO filter].Filter = "[Vendor Code] = " & Me.[Vendor Code]
Forms![PO filter].FilterOn = True
End If

End Sub
Private Sub OpenChildForm()

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

End Sub
Private Sub CloseChildForm()

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

End Sub
Private Function ChildFormIsOpen()

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

End Function

Heres the code for the PO in case you need it
Option Compare Database

Sub Form_Current()

Dim ParentDocName As String

On Error Resume Next
ParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![PO Subform].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit

End Sub
[2501 byte] By [SwordSainTII] at [2007-11-11 10:29:29]