Results 1 to 7 of 7
  1. #1
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63

    VBA to locate a file and print it

    Hello,

    I'm very new to Access and especially VBA. Can someone help me get started with the correct syntax for locating a file, and printing it. The file will be a PDF and if possible I would like to declare a variable for the file name (not the path) so if it is changed I can just change the variable instead of looking for it in the code. I plan to have 10 of these.

    Thank you in advance to anyone willing to lend a helping hand.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Not sure what you are trying to do. I understand the need to print a file, but how do you want to search for it? How do you imagine the action of locating the file?

  3. #3
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63
    I have several access forms that are almost identical to paper forms that are stored on our company server network. I would like for the user to open the access form, press a button and it prints the actual paper form located on the server network. They will then go offsite to complete the paper form, return to there desk and fill in the access form. FYI, I'm using a split database.

    I've ran macros in excel that open other files by the following code:
    Code:
    Workbooks.Open ("\\myFilePath")
    I was hoping access had the same capabilities, only instead of open, it would simply print.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    The answer is you log the path at the time the "form" is printed into a field in a table.

    Having said that, post #3 is causing some confusion for me. When I hear the term, "Access form", I think of an Access Object that is a part of an Access database file. Opening an Access form allows users to view and or input data directly into tables in Access database files.

    If Access is printing a PDF file located on a network share and you want to search for that same file at a later date, you should store the path of the PDF file at the time it is printed.

  5. #5
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63
    Correct.

    Just to clarify, I have a navigation form that is linked to 10 forms. Each form represents an audit sheet that the user needs to input data. Before they input data they need to collect it first. Thats why I was hoping for a way where they can press a button and access will print a procedure(pdf, not access related) for the user to collect there data on. The procedure is a pdf that is completely separate from access.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Printing files is not complicated. You need to know the path to the file. Discovering the path can be done with the user's input via a Windows file picker.

    I prefer not to depend on user input for these situations and will instead keep track of the paths for important PDF files. I use Windows Active Directory to create permissions that restrict movement of and the editing of these protected files. These permissions ensure the hardcoded paths will always work.

    You can also use a file picker in conjunction with a secure directory by hard coding a default location to begin in.

  7. #7
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63
    Awesome thank you for your help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Cannot locate my saved report
    By tstoneami in forum Reports
    Replies: 1
    Last Post: 08-01-2013, 09:38 AM
  2. Locate match in two columns
    By jill27 in forum Queries
    Replies: 3
    Last Post: 03-01-2013, 01:44 PM
  3. Can not locate values in recordset
    By lawdy in forum Programming
    Replies: 8
    Last Post: 02-01-2013, 11:18 PM
  4. Cannot locate VBA code for MsgBox!
    By sjl in forum Forms
    Replies: 5
    Last Post: 12-20-2011, 05:26 PM
  5. cmd to print/view an MS-Excel file
    By gkast in forum Forms
    Replies: 0
    Last Post: 11-23-2008, 07:39 PM

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