Linked forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
You are describing "how" you want to do something. What I'm not clear on is
"what" you want to do. Can you describe what you want to achieve, but in
terms that don't include any mention of specific techniques?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
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.
 
Hi Jeff:
Please see my reply to Dan.
Thanks,
J

Jeff Boyce said:
You are describing "how" you want to do something. What I'm not clear on is
"what" you want to do. Can you describe what you want to achieve, but in
terms that don't include any mention of specific techniques?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
What is the code "behind the button"?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
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. 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.

Jade5 said:
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.
 
Problem: 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.

Response:
I didn't actually encounter that problem, when I designed a similar form.
There alot
of reason that might cause that problem: control property, form property,
changing property by code, etc.

Best Solution:
The best solution to find the error quickly create 1 new form. A continuous
form
with your company and add the command button to open your subform. Do not
change any of the property of the command button and apply the code. Test
out the form, and
see what different from your original form.



Jade5 said:
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.

Jade5 said:
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.
 
Thanks Dan. I'll try that. J

Dan Dang said:
Problem: 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.

Response:
I didn't actually encounter that problem, when I designed a similar form.
There alot
of reason that might cause that problem: control property, form property,
changing property by code, etc.

Best Solution:
The best solution to find the error quickly create 1 new form. A continuous
form
with your company and add the command button to open your subform. Do not
change any of the property of the command button and apply the code. Test
out the form, and
see what different from your original form.



Jade5 said:
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.
 
Back
Top