Open file based on combobox selection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mack guy
    New Member
    • Jan 2008
    • 2

    Open file based on combobox selection

    I'm working on an Access database and have a form with a combo box (a list of assembly plant locations), and I want a command button that will open the layout file for that plant.

    I've got
    Application.Fol lowHyperlink "<file location>"
    which works, but I'm looking for a way to control what file is opened based on the selection in the combobox.
    I tried
    If ([Combo154]="<plant name1> Then
    Else
    If ([Combo154]="<plant name1> Then


    Etc...

    I also tried

    If Combo154.Text.C ontains("<Plant name>" Then

    Etc

    However both of those just made the command button do nothing (didn't even return error code)

    Any suggestions?
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    My first suggestion would be to put a break point in the code, run it, stop and display the values that the code is working with. Then you can determine why your IF isn't working as expected.

    Get to know the VB debugging tools, they can be your best friend at a time like this.

    Comment

    • Mack guy
      New Member
      • Jan 2008
      • 2

      #3
      How would I do that? I'm new to VB, mostly let access create my code for me, and then just tweak it to do what I want. This project is my first real exposure to it.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by Mack guy
        How would I do that? I'm new to VB, mostly let access create my code for me, and then just tweak it to do what I want. This project is my first real exposure to it.
        Oh. Hope you're having fun, then.

        Just put your cursor on the line where you want to interrupt execution, and hit F9. That should do a red highlight to show there's a breakpoint there. Then, when the code is executing and reaches that line, it will pause (before executing it)and wait for you to tell it what to do.

        Using the tools available on the Debug toolbar (also on the Debug menu), you can then view or modify variable values, execute one statement at a time, and so on. Have a look through the documentation for the debugging tools, as they are invaluable for this sort of stuff.

        Comment

        Working...