Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Help needed - how to link a combo box to a subform

$
0
0
Hi,

Please can someone help?! I am trying to link a combobox in a main form to a subform. So, when a particular option in the combobox is selected the relevant subform will open within the main form.

I have never written code before, but appropriated the code pasted below, which I have linked to the combobox in Properties > Event > On click > [Event Procedure]. However it won't work! Please can you take a look at it and see where there could be an error?

Many thanks! :-)

________________

Option Compare Database

Private Sub Combo93_Click()

End Sub

Sub ShowSubform()

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

'Display appropriate subform based on ProjectType chosen
If ProjectType = "Audit" Then
SubFormAudit.Visible = True
SubFormServEvalPN.Visible = False
SubFormServEvalQIS.Visible = False

ElseIf ProjectType = "Fac UK" Then
SubFormAudit.Visible = False
SubFormServEvalPN.Visible = False
SubFormServEvalQIS.Visible = True

ElseIf ProjectType = "Obs Overseas" Then
SubFormAudit.Visible = False
SubFormServEvalPN.Visible = True
SubFormServEvalQIS.Visible = False

Else
SubFormServEvalQIS.Visible = False
SubFormAudit.Visible = False
SubFormServEvalPN.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 MediaType
Call ShowSubform

End Sub

Private Sub ProjectType_AfterUpdate()

'Call subroutine to display appropriate subform based on MediaType
Call ShowSubform

End Sub
________________

Viewing all articles
Browse latest Browse all 13329

Trending Articles