Results 1 to 14 of 14
  1. #1
    Join Date
    May 2006
    Posts
    386

    Unanswered: Can anyone suggest How can I create a Form with Some buttons to link to files?

    I have been asked by my boss to create a page (form) which should have 15 to 18 buttons on it and each button should open one file at a time exactly as if they are linked.

    We send articles to clients every week on CDs but we want each article (file) to be opened by a single click on a button. Until now we have been saving the articles as individual files on CDs and were sending them to client. BUT now, we want to create a page (form) in Ms Access with 15 to 18 buttons and every time we send Articles to clients we should just upload/link each file through each button e.g . each button should open one file at a time and our clients should be able to open each file without searching the files on a CD.

    I created fields with hyperlink but they are no good, because when i burn them on CD the links wont open because our clients may use different drives etc.

    Any help and idea would be greatly appreciated.
    Emi-UK
    Love begets Love, Help Begets Help

  2. #2
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    what about something like this:
    Code:
    Option Explicit
    Dim strPath As String
    
    Private Sub Form_Load()
       Dim strName As String
       
       'gets the full path (including filename) of the database you're in
       strName = CurrentDB.Name
    
       'saves just the path to the database in strPath
       strPath = left(strName,len(strName)-len(dir(strName)))
    End Sub
    
    Private Sub cmdOne_Click()
       <syntax to open file> strPath & <file #1 path>
    End Sub
    
    Private Sub cmdTwo_Click()
    .
    .
    .
    you may need to tweak it a bit, but it should allow you to reference files on the same disc. So if they have it in drive D:, strPath will be D:. If it's in drive E:, strPath will be E:. Then you can add on the path to your filename (i.e. "\files\fileone.doc").

    Hope it helps.

  3. #3
    Join Date
    May 2006
    Posts
    386
    Thank you for your time. What will this do? will it enable me to just click on a button which will allow me to select a file and then the file will be saved behind the button? or will it have a path to the file in a separate field? I basically want something like An enter face form with many buttons on them, each button should be renamed everytime I send out articles to my clients and each button should open a file even after I burn the form on the CD.

    Your kind guidance would be much appreciated.
    Emi-UK
    Love begets Love, Help Begets Help

  4. #4
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    Well, I was thinking that you'd change the path for each filename manually each time before you burnt the cd. This is the "quickest" way to get a working program that I can think of.
    A better way that you could keep using would be to maybe have the form with the buttons that when you click each one, it launches a common dialog box, and stores the selected file path (relative to the database) in a table (with fields for Button Name, File Path, and button caption). Then you could have another form which loads on runtime and shows the buttons that when clicked, do a
    Code:
    <syntax for opening> Dlookup("fldFilePath", "tblInfo", "[fldButtonName]=" & Me.ActiveControl.Name)
    Also, in the form_load() of that form, you could have
    Code:
        Dim btn As CommandButton
        
        For Each btn In Controls
            btn.Caption = DLookup("fldButtonCaption", "tblInfo", "[fldButtonName]='" & btn.Name & "'")
        Next btn
    these are kinda abstract thoughts, but should work. maybe a typo or two in there. let me know if it works out (or doesn't)

  5. #5
    Join Date
    May 2006
    Posts
    386
    Yes you are right, that is how i want. a simple db with only one or two forms which clients should only be able to see one form and everytime i want to send the files to clients I should be able to manually click on the buttons and rename the button and send it to client in mde format. I am just send you an image of the kind of form and function I want to have. I hope this enables you to help me better with few simple fields if on a simple form if possible.
    THANK YOU SO MUCH FOR YOUR HELP.
    Attached Thumbnails Attached Thumbnails Test Image.bmp  
    Emi-UK
    Love begets Love, Help Begets Help

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    depending on what else you are distributing on the CD, and whether or not that requires Access.. Personally I'd be minded to deploy this as a web page... and not use Access at all
    if the cd has a html file called index.htm it should be automatically opened on inserting the cd into the drive (depending on your customers security settings).. heck it may actually be better to deploy the whole thing as a web page and not get involved in the cost of the cd repro.

  7. #7
    Join Date
    May 2006
    Posts
    386
    Yes, I was also not very sure whether Access would be a better option. Thank you for your help. I think, I have to try it in html and see if I can manage it. Thank you once again for your help and advice. Have a wonderful New Year.
    Emi-UK
    Love begets Love, Help Begets Help

  8. #8
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    HTML may indeed be a better option. If you do still want to do it in access, though, here's a sample db I put together. It's only got two buttons, but it works like we've described. Click a button on Admin form and choose a file and give caption. Click button on user form and it launches the file. Bear in mind, there's no formal errorchecking, which you definitely would want to do before putting out to clients. Whichever way you go, good luck.

    P.S. one of the main assumptions built into this database is that the files you're referencing are all in a subdirectory of the folder the db is running from.
    another is that the filetype you're trying to open is registered.

    Quote Originally Posted by Emal
    Yes you are right, that is how i want. a simple db with only one or two forms which clients should only be able to see one form and everytime i want to send the files to clients I should be able to manually click on the buttons and rename the button and send it to client in mde format. I am just send you an image of the kind of form and function I want to have. I hope this enables you to help me better with few simple fields if on a simple form if possible.
    THANK YOU SO MUCH FOR YOUR HELP.
    Attached Files Attached Files

  9. #9
    Join Date
    May 2006
    Posts
    386
    Hi Jmahaffie, That is absolutely what I want. Thank you very much. The only problem I have enountered was when I copied and pasted the same buttons and renamed them as Cmdthree and CmdFour on both the Admin form and Useform, I get this error
    Runt-time error '94' Invalied use of Null
    I will greatly appreciate if you could tell me what might be the problem?

    I have also created the same code on the 'Click event procedure' of the other two buttons and renamed them accordingly.
    Emi-UK
    Love begets Love, Help Begets Help

  10. #10
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    that's what i get for not running it before i sent it. try this one. note the changes in the RefreshButtonCaptions sub on frmAdmin and Form_Load on frmUser
    Attached Files Attached Files

  11. #11
    Join Date
    May 2006
    Posts
    386
    PERFECT. THANK YOU very much. I now have to find out how to autrun this on inserting the CD.

    You mentioned that this run on anycomputer as long as the db and the files are saved in the same folder?

    Thank you so much.
    Emi-UK
    Love begets Love, Help Begets Help

  12. #12
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    it should, since you're not hardcoding any paths (i.e. D:\Articles\article1.doc).
    Provided your db is in the root of the volume, and the files are at the same level or lower, it should work just fine. burn one (a CD) and try it out.

  13. #13
    Join Date
    May 2006
    Posts
    386
    That is Perfect. it works. Thank you once again.
    Emi-UK
    Love begets Love, Help Begets Help

  14. #14
    Join Date
    May 2006
    Posts
    386
    Hi Jmhaffie, again me. Sorry to disturb, Actually I just inserted an image in the UsrForm and and changed the color and also inserted a lable with some text in it. When I run the form again, I get this error ' Runtime Error 13' Type mismatch Any idea why i get this error? i even have not added another button. When I click on Debug, It highlights this code
    Next btn
    Thank you for your help Jmahffie.
    Emi-UK
    Love begets Love, Help Begets Help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •