Problem with Opening Subform

S

sue gray

I have a main form (frmTxPlanHxMH) that opens a subform (frmTxPlanMH) from a
command button. frmTxPlanMH contains 5 subforms laid out in pages. My
problem is that when I open frmTxPlanMH none of the 5 subforms are there. I
see the tabnames but not the fields on the forms. But when I close
frmTxPlanMH and then open it from another command button to open it in read
only the forms show up.

tblclient - pk - clientid
tbltxplanmh - pk txplanMHID
one to many - clientid from tblclient to clientid from tbltxplanmh

Here's the code for the command buttons. Thanks for any help it's greatly
appreciated.

Private Sub AddTxPlan_MH_Click()

On Error GoTo Err_AddTxPlan_MH_Click

Dim strDocName As String

strDocName = "frmTxPlanMH"

DoCmd.OpenForm strDocName, , , , acAdd, , Me!clientid

If IsNull(Forms!frmtxplanmh!clientid) Then
Forms!frmtxplanmh!clientid = Me!clientid
End If


Exit_AddTxPlan_MH_Click:
Exit Sub

Err_AddTxPlan_MH_Click:
MsgBox Err.Description
Resume Exit_AddTxPlan_MH_Click

End Sub


Private Sub View_TxPlan_MH_Click()
On Error GoTo Err_View_TxPlan_MH_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmTxPlanMh"

stLinkCriteria = "[txplanMHid]=" & Me![txplanMHID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly

Exit_View_TxPlan_MH_Click:
Exit Sub

Err_View_TxPlan_MH_Click:
MsgBox Err.Description
Resume Exit_View_TxPlan_MH_Click

End Sub
 
M

Marshall Barton

sue said:
I have a main form (frmTxPlanHxMH) that opens a subform (frmTxPlanMH) from a
command button. frmTxPlanMH contains 5 subforms laid out in pages. My
problem is that when I open frmTxPlanMH none of the 5 subforms are there. I
see the tabnames but not the fields on the forms. But when I close
frmTxPlanMH and then open it from another command button to open it in read
only the forms show up.

tblclient - pk - clientid
tbltxplanmh - pk txplanMHID
one to many - clientid from tblclient to clientid from tbltxplanmh

Here's the code for the command buttons. Thanks for any help it's greatly
appreciated.

Private Sub AddTxPlan_MH_Click()

On Error GoTo Err_AddTxPlan_MH_Click

Dim strDocName As String

strDocName = "frmTxPlanMH"

DoCmd.OpenForm strDocName, , , , acAdd, , Me!clientid
[snip]


A subform will not show if there are no records to display
and a new record can not be added. Your use of acAdd
specifies that existing records should not be displayed so I
conclude the subforms' record source queries are not
updatable.
 
S

sue gray

you were correct - thanks for the help

Marshall Barton said:
sue said:
I have a main form (frmTxPlanHxMH) that opens a subform (frmTxPlanMH) from a
command button. frmTxPlanMH contains 5 subforms laid out in pages. My
problem is that when I open frmTxPlanMH none of the 5 subforms are there. I
see the tabnames but not the fields on the forms. But when I close
frmTxPlanMH and then open it from another command button to open it in read
only the forms show up.

tblclient - pk - clientid
tbltxplanmh - pk txplanMHID
one to many - clientid from tblclient to clientid from tbltxplanmh

Here's the code for the command buttons. Thanks for any help it's greatly
appreciated.

Private Sub AddTxPlan_MH_Click()

On Error GoTo Err_AddTxPlan_MH_Click

Dim strDocName As String

strDocName = "frmTxPlanMH"

DoCmd.OpenForm strDocName, , , , acAdd, , Me!clientid
[snip]


A subform will not show if there are no records to display
and a new record can not be added. Your use of acAdd
specifies that existing records should not be displayed so I
conclude the subforms' record source queries are not
updatable.
 

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