Page 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 53
  1. #31
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    Add this line of code
    Code:
     
     If Dir(strFile) = "" Then
        Msgbox "Cannot find " & strFile,vbExclamation+vbOkOnly,"Unable to open Excel File"
       Exit Sub
    End If
    Step though your code and see what happens

    David

  2. #32
    viper550 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    28
    I lost you completely.Where should i add this code?In the button?

  3. #33
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    Directly after the Replace line on the button click event.

    David

  4. #34
    viper550 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    28
    I get a compile error in the sPath line.

    I also told you that i didnt understand how i am supposed to link the files with the combo boxes selection.You didn't make that clear.

    Can i ask you something?Are we doing what i asked you about the first form (1 combo box,1 button opening excel) or the second form (4 combo boxes,1 button,opening photo files)?I am asking because i am a little lost.

  5. #35
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    You tell me? I thought that the first form issue on the main subject of this post "Cascading Combo boxes" had been resolved. Your send for is just a continuation of the exercise.

    What I have attempted to provide you with is the knowledge of how they work. And as an added bonus I have given you some well proven code that will open a file, no matter what type, in the native software for that particular file.

    However what may be confusing you is the title of the message box, which is my fault, it should be stating that the image does not exist in the named folder.

    You may also need to Dim strFile as String as the top of the form as well.

    David

  6. #36
    viper550 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    28
    Yes the first part in how to link the combo boxes is ok.I now understand this.But i also asked how to open a file with each selection of the combo box.So this code you gave me will work for both the forms i want to create?If yes then you still haven't explained how the code works.How will it know with each selection which file to open?This is the connection that i haven't understood yet.

    As for the code it still says compile error : Syntax error.

    Be patient with me mate.I need to do baby steps with this.You have helped me alot until now and im grateful if we can finish this in success.

  7. #37
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    At some point in the process you are going to need to provide a path and a file name that can be used by the code to open the image file. This action need to be determined by yourself.

    As you say you think you have masted the cascading combos process. Whether it be 2, 4 or 44 cascades.

    In the 4 part senario

    Manufacturer 1 > Compressor 1 > 1st stage > Piston ring
    Manufacturer 1 > Compressor 1 > 3rd stage > Piston ring

    lets make up a little example using the bound column of the combos

    Manufacturer 1 has been coded 01
    Compressor 1 has been coded 01
    stage 1 has been coded 01
    stage 3 has been coded 03
    piston ring has been coded 20

    If we concat them together

    strFile = Me.Cbo1 & Me.Cbo2 & Me.Cbo3 & Me.Cbo4 & ".Jpeg"

    so in the first example strfile translates to

    01010120.jpeg

    in the second

    01010320.jpeg

    so the name of the jpeg file we are looking for either 01010120.jpeg or 01010320.jpeg

    Code:
     
    If Dir(strFile) = "" Then
       Not Found
    Else
       Found
    End If
    Now I don't know how you have named you jpegs but something on the lines of what I have suggested will attempt to resolve the image file name.

    Is this what you mean?

    David

  8. #38
    viper550 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    28
    Thank you for using your time trying to make me understand.

    As for what i havent understand in your code is where does it say that when i select for example the first name in the combo box it will open the corresponding excel file.That is what have confused me.I see where to put the path for the folder and the file name but i dont know where i have to specify which selection in the combo box goes with that file name.For example the CCHBC Aigio selection opens the CCHBC Aigio file.I have set the file name but where do i have to write about the CCHBC selection.I figure that some part of the code,since i have many selections in the combo box, i will have to write multiple times.Is that correct?

    Also about the 2nd form.Brilliant idea.I was thinking about a way to name the jpegs for easy finding and your idea is the best.I will follow that.As for the code.Where do i specify the selection of all combo boxes in order to open the image.(I figure it must be the same as with the other form or similar).

  9. #39
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    In your manufactuers table you have one called CCHBC Aigio for example, so you need to add another field that will contain the name of the CCHBC Aigio spreadsheet.

    TblManufacturers:
    ManID: 1
    ManName: CCHBC Aigio
    ManExcel: CCHBCAigio.xls

    Then in your combo you row source will be

    Select ManID,ManName,ManExcel From TblManufacturers Order By ManName

    Combo Properties

    Columns: 3
    Column Widths: 0cm,3cm,0cm
    Bound Column: 1

    Now when you select CCHBC Aigio from the combo box in the after update event you would code

    strFile = Me.Cbo.Column(2) Which is actually the third column because Access always start at zero.

    so strfile will return CCHBCAigio.xls

    David

  10. #40
    viper550 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    28
    the code on the on-click event of the button will stay the same as you told me?

    UPDATE
    ok i made the changes necessary for the first form to work.All excel files open without a problem.Thank you so much!!!

    I will try to make it work for the second form now.Since it is a little more complicated i will try to make one sample to see if it works and i will report back.

  11. #41
    viper550 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    28
    Ok i have tried the first form since yesterday adding more names to the combo box and no problems there.This one is solved.

    Now for the second form.I have tried the same thing i did for the other one but i get an error.

    To give you an idea of what i did for the code you gave me for the on-click event of the button i deleted the first 3 lines (sPath and strFile lines).After that i added another column in the tables as you told me but instead of writting only the file i wrote the whole path file.This way it gets the path from the table.

    Although i did the same thing in the first form,for the second form(4 combo boxes,1 button) when i make a selection in the fourth combo box i get "Run time error '94' : Invalid use of Null " error.I checked everything if i have made a mistake somewhere but nothing has changed.

    Any ideas?

  12. #42
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    When you get the error select debug and it will go to the line in the code that is rasing the error. hover over any variables or fields contained in that line and check for Null values. That will be the source of your error.

    David

  13. #43
    viper550 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    28
    The error appears in the after update event of the fourth combo box.The code there is:

    strFile = Me.Combo7.Column(3)

  14. #44
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    So ask yourself is there anything to select in the fourth column in that combo box. For debugging purposes make all the columns visible by giving them a width and ensure that the 4th column (.Column(3)) is populated.

    David

  15. #45
    viper550 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    28
    Ok something strange is going on.

    I did what you told me.I made visible all the columns in the 4th combo box.The problem is that the values of the 4th column (the paths in our case) are not visible.But this occurs only if i try to select a value after i made a choice in the other 3 boxes.If i open the 4th combo box without selecting anything from the others the 4th column with the paths shows correctly and if i select it and press the button the image opens.

    The problem only appears if i try to select from all the combo boxes.

Page 3 of 4 FirstFirst 1234 LastLast
Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums