Results 1 to 8 of 8
  1. #1
    dandoescode is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    85

    Envirormental Variable

    Okay so I want to add a reference file using
    Code:
     References.AddFromFile ("FileLocation.BlahBlahBlah")
    The issue is that the file location is variable. I can be certain about the name of the folder and the file name, however the drive the folder will be located on will not. I think the way to go about doing this would be using an Envirorment variable %ProgramFiles% perhaps, but I dont really know. Anybody have any ideas?

  2. #2
    dandoescode is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    85
    Found the solution myself.
    Code:
    Dim prgFiles, winFiles As String
     prgFiles = (Environ("ProgramFiles"))
     winFiles = (Environ("Windir"))
    References.AddFromFile (prgFiles & "\Microsoft Office\Office14\MSACC.OLB")

  3. #3
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    dude, just use the file dialog picker. it's that simple. if no file is chosen, it returns a zero length string.

  4. #4
    dandoescode is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    85
    Would this open a dialog box to choose a file?

  5. #5
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    you indicated this is solved, but the answer is YES. by definition sir, that's what it does. that's what the word "dialog" generally means. it has like 3 or 4 extensions in vb6. it has a folder spec, file spec and a couple others. there are also numerous properties associated with the object that are useful because they can restrict the user from getting into trouble by clicking around windows aimlessly (or also by trying to be cute!).

  6. #6
    dandoescode is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    85
    Yeah, well see I dont want the dialog box to open in this case. This vba is going to run everytime the db opens and check to see if it has the required references, and then add any missing ones, it needs to be completely in the background.

  7. #7
    dandoescode is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    85
    Sort of a refresh and repair tool if you will.

  8. #8
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    k. .,............

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

Similar Threads

  1. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  2. Object variable or With block variable not set
    By walter189 in forum Programming
    Replies: 1
    Last Post: 07-28-2011, 08:51 AM
  3. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  4. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  5. Variable Criteria
    By JamesLens in forum Queries
    Replies: 0
    Last Post: 01-02-2009, 04:55 PM

Tags for this Thread

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