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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Form From List/Combo Box Selection?

Status
Not open for further replies.

tpearo

Technical User
Apr 24, 2000
124
US
Is it possible to have a list box that lists the forms in your database and allow the user to select a form from the list and when selected launch or open that particular form?
I have about 8 forms that have fields that need to be filled out based upon the testing my technicians do in my lab. I want them to be able to select the test that they will perform based on a drop-down or list box... and when they select the test it open the appropriate form for that test.
Any help would be appreciated.

Tp
 
Code:
Private Sub ComBox1_AfterUpdate()
    DoCmd.OpenForm Me.ComBox1.Column(0)
  End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
And for the list you could use:
Code:
Private Sub Form_Load()
Dim frm, strForms
For Each frm In CurrentProject.AllForms
    strForms = strForms & Chr(34) & frm.Name & Chr(34) & ";"
Next
strForms = Left(strForms, Len(strForms) - 1)

Me.cboForms.RowSourceType = "Value List"
Me.cboForms.RowSource = strForms
End Sub

Private Sub cboForms_AfterUpdate()
DoCmd.OpenForm cboForms
End Sub

 
O.K.
But how do I link the form to the selection in the combo box. For example I have five selections in the combo box
1. Final
2. F/A
3. Photo
4. 2nd Final
5. S/F
And I have 5 different forms that have different fields depending on the selection above. So how do I tell the system to open the Final form when the user selects Final...
or if the user selects F/A then open the F/A form.

Thanks for your help.

Tp
 
Use ZmrAbdulla suggestion, and add an extra column for form name:
[tt]DoCmd.OpenForm Me.ComBox1.Column(1) 'Column 0 = eg Final[/tt]
(Don't forget to set Column Count to Number of Columns - 1)
Or else use a case statement:
[tt]Select Case ComBox1
Case "Final"
DoCmd.OpenForm "Final Form"
Case "F/A"
... etc
End Select[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top