Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple subforms and combo-box

Status
Not open for further replies.

emitecaps

Technical User
Apr 20, 2005
24
GB
Hi,

I'm v.new to Access so do excuse my ignorance.
I have a form with a combo-box with the following values:
Trust, Course, Overseas, GP
When Trusts is selected I'ld like frmtrust_sub to appear.
When anything else is selected I'ld like frmnontrust_sub to appear
Once the data has been entered in the subform the user would continue back to the main form.
I'ld like the subforms to remain hidden until needed, if possible so as not to confuse users.

I’ve copied this piece of code and have tried pasting it into the “after update” event procedure but I get this error message

“the link masterfields property section has produced this error “Ambiguous name detected: Type_afterupdate”


Private Sub Type_AfterUpdate()

Option Compare Database

Sub ShowSubform()

'Save unsaved changes to currently open subform
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

'Display appropriate subform based on Type chosen
If Type = "Trust" Then
frmtrust_sub.Visible = True
frmnontrust_sub.Visible = False

ElseIf Type = "GP" Then
frmnontrust_sub.Visible = True
frmtrust_sub.Visible = False

ElseIf Type = "Course" Then
frmnontrust_sub.Visible = True
frmtrust_sub.Visible = False

ElseIf Type = "Overseas" Then
frmnontrust_sub.Visible = True
frmtrust_sub.Visible = False

ElseIf Type = "Other" Then
frmnontrust_sub.Visible = True
frmtrust_sub.Visible = False


End If

End Sub

Private Sub cmdClose_Click()

'Close form
DoCmd.Close

End Sub

Private Sub Form_Current()

'Call subroutine to display appropriate subform based on template type
ShowSubform

End Sub

Private Sub Type_AfterUpdate()

'Call subroutine to display appropriate subform based on template type
ShowSubform

End Sub


Any help would be greatly appreciated

thanks

Barry
 
How are the two subforms linked to the mainform ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
i've checked and the code is incorrect....each incidence of "Type" in the code should read "Type_"
changing this has got rid of the error message.
In my table I have a column called "client" - this is filled with the name selected in either subform - if it's a trust then it will be the trust name etc.

each subform has link child = trust, master child = client
i've tidied up the code to read


Private Sub Type_AfterUpdate()

'Call subroutine to display appropriate subform based on template type
ShowSubform

End Sub

Sub ShowSubforms()

'Save unsaved changes to currently open subform
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

'Display appropriate subform based on Template_type chosen
If Type_ = "Trust" Then
frmtrust_sub.Visible = True
frmnontrust_sub.Visible = False

ElseIf Type_ = "GP" Or Type_ = "Course" Or Type_ = "Overseas" Or Type_ = "Other" Then
frmnontrust_sub.Visible = True
frmtrust_sub.Visible = False

End If

End Sub

I still find both subforms on the screen
Do i need to add a before update to type?

thnks barry

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top