Choose form to open from drop down list

I use prefixes btw... I thought that WAS the convention... :s

i name my forms frmWhatever and subfrmWhatever...
vbaInet didn't mean that. What they meant was for identifying which forms to include in the list. I use the underscore after frm to do it. So, until I want the form in the list it is named frmMain and then when I want it in the list I rename to frm_Main and it is there. :) ;)
 
Oh, and glad we could help you out. :)

thumbsupsmile.jpg
 
gotcha!

Thank you again!!!
 
True about the subforms Bob. I don't always follow tradition, I use postfix "_sub" :D

Glad Bob's solution worked for you. All thanks to Bob. Woop!
 
Hi again guys,

I have another small issue with this form. I used vbaInet's code to open the form chosen in the drop down list as follows:

Dim stDocName As String
Dim stLinkCriteria As String
If cboPMMForms.ListIndex > -1 Then
DoCmd.OpenForm cboPMMForms.Value
End If

Now the problem that I have here is that the items listed in my drop down list must have the same name as the form I wish to open. For instance, the list will give the user 3 choices : Form1, Form2, Form3. Once a choice is made and the button is pressed the form with the same same as the selected one will open.

The problem I have is that since I use normalized names i.e. frmPMM1, frmPMM2, frmPMM3, etc. I would like the user to see the title of the form instead of it's filename i.e. "Monthly business form, Monthly call form, monthly diagnostics form, etc."

Right now the information is pulled from a table that has 3 fields : #1 : FormID (autonumber, primary key) #2 FormName (actual filename for the form "form1, form2, etc.", #3 FormTitle "Monthly business form, etc."

I thought it would be as simple as telling the code to chech the information in column 2 with something like this :

cboPMMForms.Value(2)

but that didn't work.

Any ideas?
 
Check the COLUMN COUNT property of the listbox and ensure it's 3. Also, ensure that the COLUMN WIDTH property is set correctly as well.
 
Sorry about the delay, I was busy on something else but that worked perfectly!

Thank you again!
 
Lol :D I wonder where Bob gets all these images.

I Google for them and then store them on my website and have an Access database which displays them to me and has the URL's stored. I just have to click a button to copy the whole image tag for the forum here along with the path, and then I just paste it in here.
 
I know I am late to this party but I like to use a select case in the after update event of a combo box when I need the users to select a listing of reports or forms to open. That way I can easily define the name the user sees in the combo box and not have to use a different naming convention for my db objects. I usually have other stuff going on depending on what value option the user selected but this is what the bare bones looks like...

Code:
    Dim sFormName As String

    Select Case cboOpenForm
        
        Case "Form # 1"
            sFormName = "frmNumber1"
            
        Case "Form # 2"
            sFormName = "frmNumber2"
            
        Case "Form # 3"
            sFormName = "frmNumber3"
            
        Case "Form # 4"
            sFormName = "frmNumber4"

        Case Else
            'Do nothing
    End Select

    DoCmd.OpenForm sFormName
 
I know I am late to this party but I like to use a select case in the after update event of a combo box when I need the users to select a listing of reports or forms to open. That way I can easily define the name the user sees in the combo box and not have to use a different naming convention for my db objects. I usually have other stuff going on depending on what value option the user selected but this is what the bare bones looks like...

Code:
    Dim sFormName As String

    Select Case cboOpenForm
        
        Case "Form # 1"
            sFormName = "frmNumber1"
            
        Case "Form # 2"
            sFormName = "frmNumber2"
            
        Case "Form # 3"
            sFormName = "frmNumber3"
            
        Case "Form # 4"
            sFormName = "frmNumber4"

        Case Else
            'Do nothing
    End Select

    DoCmd.OpenForm sFormName

I don't like hard-coding any of that. But as you say, it is another way. Another way is to have the report names and friendly names in a table and then use that table as the combo's row source. I think that would be better than hard-coding values in code. Then you never have to modify it to handle a new form or report, much like my own method.
 

Users who are viewing this thread

Back
Top Bottom