Multiple combobox selections to open subform

thinair421

Registered User.
Local time
Today, 08:00
Joined
Jun 22, 2010
Messages
34
Hi,

Below is a screen shot of the layout for what I want to do will look like. I have absolutely no VBA knowledge, although I will be reseaching it extensively today and in the days to come.

What I am trying to do is select any combination of choices from the three combo boxes at the top (I have seleced an example set of choices in the image), and based upon the selection, I would like a specific form to open in the box below. Can anyone help get me started? Thank you in advance.

Setup for combo boxes:

Task: [Numbers 1-3] [Letters A-F] Tank Number: [several different options here]
 

Attachments

  • form.JPG
    form.JPG
    55.5 KB · Views: 157
... I would like a specific form to open ...

A different form depending on the inputs or a specific record from the same subform?

If a specific record, then you can just use the Filter property of the subform based on the inputs from the combo boxes.

-dK
 
A different form based upon the selected criteria would popup below.

EDIT: (I know this is essentially a switchboard concept, but I would like to handle it all through the same master form.)
 
Last edited:
You will need to set up the logic behind a 'Go' button through VBA that would either need to be of the If-Then or Select Case (or combination therof) that would then allow you to set the recordsource property of the subform.

For instance ... If cboCombo ="1" Then Me.SubFormName.SourceObject = "SomeFormName".

Obviously you would need to expand this logic depending on your state diagram of how you want the execution to occur.

-dK
 
Thats exactly what I was thinking...

Its very simiar to a switch statement with If/Else statements too that I learned in a C++ class a long time ago (which I've forgotten how to code)

Each case, when satisfied, will adjust the controlsource of the subform...

So I'm assuming that this code is going to be very indepth and complex...now my only issue is how to actually write this code, and where exactly it goes.
 
You can set up a table with the form that it should open based on the values input.

Something like:

tluForms
lookupID - Autonumber (PK)
NumSel - Integer
LettSel - Text
TankSel - Text (or number depending on its makeup)
FormSel - Text (store the form name to open)


And then you can use a single DLookup to get the form to use:
Code:
Dim strForm As String

strForm = Nz(DLookup("FormSel", "tluForms", "NumSel =" & Me.ComboWithNumber & " AND LettSel = " & Chr(34) & Me.ComboWithLetter & Chr(34) & " AND TankSel = " & Chr(34) & Me.ComboWithTank & Chr(34)),"")

If strForm <> "" Then
   Me.YourSubformControl.SourceObject = strForm
Else
   MsgBox "No form is available to select for that combination", vbExclamation
End If
 

Users who are viewing this thread

Back
Top Bottom