1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development MS Access VB find, and save file

Discussion in 'Software' started by jopers1986, 23 Jul 2013.

  1. jopers1986

    jopers1986 Minimodder

    Joined:
    7 Jan 2005
    Posts:
    559
    Likes Received:
    4
    Hi all!!

    Long time since i've posted on bit-tech, have turned into a lurker!

    I'm having a head ache with a database i'm makeing for work, and am now stumped and was hoping someone out there would be able to help.

    My Visual Basic is... well... basic!

    I have a the database stored on a networked drive, and i need the users to be able to find a file, ideally using the standard windows open dialog box, (but not actually open it, just find store the file location to use) then rename it, save it to a standard location on the network drive and log it in a table on the database.

    I've found the below link to the OpenFile function and have tried it, but really can't get it to work...

    http://access.mvps.org/access/api/api0001.htm

    Can anyone help me pleeeease treating me as an idiot!?!?!?!?!

    Thanks!!!
     
  2. deathtaker27

    deathtaker27 Modder

    Joined:
    17 Apr 2010
    Posts:
    2,238
    Likes Received:
    186
    why do they need to rename it and store it on the server, you could write a script to do that a lot easier?
     
  3. jopers1986

    jopers1986 Minimodder

    Joined:
    7 Jan 2005
    Posts:
    559
    Likes Received:
    4
    That's ideally what i'd want the code to do, re-name the file after ID field in the open DB record and save it in a central location... i've got odds and ends, but can't patch anything together
     
  4. steveo_mcg

    steveo_mcg What's a Dremel?

    Joined:
    26 May 2005
    Posts:
    5,841
    Likes Received:
    80
    First what you need to do is open your connection to your table call the file dialogue function and store the outputs of that to your table.

    Code:
    Dim db as databse
    dim rs as database
    dim sfile as string, spath as string
    set db = currentdb
    set rs = db.openrecordset("select * from [yourtable]")
    
    
     With Application.FileDialog(msoFileDialogOpen)
     .AllowMultiSelect = false
    .InitialFileName = "\\default\location
    .Filter 'if appropriate
    .Show
    sFile = .SelectedItems(1) 'might be 0
    sPath = .SelectedItems(1).path 'might have made that up
    
    end with
    
    'feed file and path to your table.
    rs("File") = sFile
    rs.update
    end function
    
    
    I can't think how to do the copy off the top of my head, but the code above isn't tested so someone will have a solution (hopefully) by the time you get that coded up properly.
     
  5. bsp

    bsp Minimodder

    Joined:
    25 Dec 2010
    Posts:
    490
    Likes Received:
    21
    Can't recall if it's fixed or not.. but I think there was a vb bug for "save as".. so careful with that one.
     

Share This Page