Having trouble opening forms

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.

Here's the code for both buttons. Thanks for any help. IT's greatly
appreciated.

tbltxplanmh - txplanmhid - pk
tblclient - clientid - pk
clientid - clientid one to many relationship

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
 
J

John W. Vinson

I have a main form (frmTxPlanHxMH) that opens a subform (frmTxPlanMH) from a
command button. frmTxPlanMH contains 5 subforms laid out in pages.

This is confusing. Are these really *SUBFORMS*? IF so you don't "open" them
with code; a Subform control resides on a form (perhaps on a tab page, it
makes no difference), and has a Form object within it. You would ordinarily
just open the main form and the subforms would all be there.

For performance reasons with multiple subforms you may want to set their
SourceObject property to blank, and only assign a form to the Subform control
in the tab control's Change event - but you would *NOT* use the OpenForm
method to open a subform.

If you are using OpenForm it will *pop up* a separate Form, not display it in
a Subform.
 
S

sue gray

Sorry, my terminology is not good. I see what you are saying.

I open frmTxPlanMH from a command button - it does *pop up* a separate Form.
frmTxPlanMH contains 5 subforms laid out in pages. The 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. This only happens when I use the command button
to add. I figure I'm not passing something correctly but not sure where to
go.

Thanks for the help.
 
J

John W. Vinson

Sorry, my terminology is not good. I see what you are saying.

I open frmTxPlanMH from a command button - it does *pop up* a separate Form.
frmTxPlanMH contains 5 subforms laid out in pages. The 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. This only happens when I use the command button
to add. I figure I'm not passing something correctly but not sure where to
go.

What do you see if you open the form directly, from the forms window, rather
than from the code? Might the subforms be *BEHIND* the Tab Control, rather
than on it (this can happen if you try to drag the subforms onto the tab
page)?
 

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

Similar Threads

Problem with Opening Subform 2
Problem opening subform 0
problem opening form 2
open form help 1
Criteria when opening form 1
If, Then Button Code 1
If Statements 4
I am not "getting" it.....DoCmd. OpenForm 4

Top