Hi Dan. The code is below. I tried what you said and just applied it to the
click event and it is working. However, the buttons always looks depressed or
clicked and when I click on one button all buttons are clicked...I guess
because the same button it applied to each record. Is there a way to change
that?
Thanks,
J
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![History table subfrm].DataEntry = True
Else
Forms![History table subfrm].Filter = "[Type ID] = " & """" &
Me![Type ID] & """"
Forms![History table subfrm].FilterOn = True
End If
End Sub
Private Sub OpenChildForm()
DoCmd.OpenForm "History table subfrm", acFormDS
If Not Me![ToggleLink] Then Me![ToggleLink] = True
End Sub
Private Sub CloseChildForm()
DoCmd.Close acForm, "History table subfrm"
If Me![ToggleLink] Then Me![ToggleLink] = False
End Sub
Private Function ChildFormIsOpen()
ChildFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "History table
subfrm") And acObjStateOpen) <> False
End Function
Dan Dang said:
A little more detail would help, but i'll try anyways.
Here a simple code:
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "yourfrmname"
stLinkCriteria = "Your filter statement" 'Example [CompanyID]=
Me.CompanyID
DoCmd.OpenForm stDocName, , , stLinkCriteria
I think this is the code your already have, but keep in mind the following:
1. Make sure you apply the code to the button: on click event
2. Assuming you have a field companyID:
a. In your form place the companyID txtbox in the form footer or header
b. You can set the companyID txtbox visible property to false, if you
dont want
the user to see it.
:
Hi Dan and Jeff. Your solution worked, Dan, but nothing happens when I click
on the button beside each record. I want to be able to click on the button
and have the subform pop up. So the records in the parent form are companies
and the the subform is the history of the companies so when I click on the
button for a company, I want to see the history subform for that company pop
up in a separate window.
Thanks,
J.
:
It possilbe to do so in a continuous form:
Just simply place the button into the detail section next to the record.
Keep in Mind:
1.You wont be able to put a subform in a continuous form
:
Hello:
Is there a way to create a link button for each record in a form. Currently,
there is one button and you have to click on a record and then click on the
button to see the subform data. Is there a way to create a button for each
record?
Thanks,
J.