Using combo box to open subform

  • Thread starter Thread starter zarkov4995
  • Start date Start date
Hi RG
I dont suppose you could do me a massive favour and add this where it should go on the code i posted, and post it back to me as I am getting just a little confused as to be honest i do not understand what Call is doing
your time and patience are greatly appreciated
Fi
 
Try this for starters. RED code is to be added and Green code to be removed.
Code:
Option Compare Database
[B][COLOR="Red"]Option Explicit[/COLOR][/B]

[B][COLOR="Green"]'--Sub Call ShowSubform()[/COLOR][/B]
[B][COLOR="Red"]Private Sub ShowSubform()[/COLOR][/B]

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

'Display appropriate subform based on MediaType chosen
If MediaType = "Online" Then
   sf_VMPress.Visible = False
   sf_VMDirectories.Visible = False
   sf_VMOnline.Visible = True
ElseIf MediaType = "Press" Then
   sf_VMPress.Visible = True
   sf_VMDirectories.Visible = False
   sf_VMOnline.Visible = False
ElseIf MediaType = "Directories" Then
   sf_VMPress.Visible = False
   sf_VMDirectories.Visible = True
   sf_VMOnline.Visible = False
Else
   sf_VMOnline.Visible = False
   sf_VMPress.Visible = False
   sf_VMDirectories.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 MediaType_AfterUpdate()

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

End Sub
 
thanks for being so explanatory, hers is what i now have but am still getting Runtime Error 424

Option Explicit
Private Sub ShowSubForm()

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

'Display appropriate subform based on MediaType chosen
If MediaType = "Online" Then
sf_VMPress.Visible = False
sf_VMDirectories.Visible = False
sf_VMOnline.Visible = True

ElseIf MediaType = "Press" Then
sf_VMPress.Visible = True
sf_VMDirectories.Visible = False
sf_VMOnline.Visible = False

ElseIf MediaType = "Directories" Then
sf_VMPress.Visible = False
sf_VMDirectories.Visible = True
sf_VMOnline.Visible = False

Else
sf_VMOnline.Visible = False
sf_VMPress.Visible = False
sf_VMDirectories.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 MediaType_AfterUpdate()

'Call subroutine to display appropriate subform based on MediaType
ShowSubForm

End Sub
 
Any chance you could Compact and Repair your db and then zip it up and post it here? It would make things a lot easier. Your zip file would have to be < 394 KB to post.
 
Open Subform

Hi RG
Thanks for your offer unfortunately my internet connection went down just last night, here it is a bit messy as still very much WIP
thanks again
Fi
 
Last edited:
I made changes in the frm_VMPurchaseOrder form and added a number of comments for you to read.
 

Attachments

RG !!
How can I thank you I wouldnt have worked that out in a million years, as you can see i am pretty basic and just keep adding bits and pieces as I learn them from you wonderful people..my boss is going to be so happy

there was one wee bit that I changed as sfOnline wasnt becoming visible when this was selected from the combo
So I did this and it works brilliantly, again thank you so much for your time and patience and explanations..I have no doubt I shall call on you again and hopefully you will reply !

Case "Online"
'-- Do nothing - they're all invisible **RG
Me.Child169.Visible = True ' sf_VMOnline.Visible = True **FB
Case "Press"
Me.Child277.Visible = True ' sf_VMPress.Visible = True
Case "Directories"
Me.Child278.Visible = True ' sf_VMDirectories.Visible = True
Case Else
'-- Do nothing - they're all invisible
 

Users who are viewing this thread

Back
Top Bottom