Results 1 to 3 of 3
  1. #1
    uaguy3005 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    45

    Access tables in backend from VBA

    I have a form with a command button that opens an excel file in a specified location and populates some of the fields based on information collected in the form. I currently have the file location hard coded in the VBA and would like to change this so that the file location is stored in a table on the back end of the database and allow administrators change the file location as required. The code currently looks like the below



    Private Sub CreateQA_Click()
    ' Creates a QA and saves it to the network.


    Dim objXLApp As Object
    Dim objXLBook As Object
    Dim strQAName As String
    Dim strQAFileLoc As String
    Dim strQAFile As String
    Dim ctl As Control


    Set objXLApp = CreateObject("Excel.Application")
    Set objXLBook = objXLApp.Workbooks.Open("S:\QUALITY\QUALITY ALERTS\Quality_Alert.xlsx")
    strQAName = Me.ID & " - " & Me.Line & ".xlsx"
    strQAFileLoc = "S:\QUALITY\QUALITY ALERTS\Alerts\"


    strQAFile = strQAFileLoc + strQAName

    I'm storing the file location in a table called tblMaintenance under a field called QALocation. What do I need to replace the Red text with to pull from that table the file location?

    Thanks for the help.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    One option would be a DLookup() function.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Just an FYI.....

    "Line" (as in Me.Line) is a reserved word in Access and shouldn't be used as an object name.
    For a list of reserved words, see http://allenbrowne.com/AppIssueBadWord.html
    Also, I am not crazy about "ID" as a name either. (not very descriptive)

    Using special characters and spaces (except the underscore) is not a good practice. It will/can cause you headaches.
    See http://access.mvps.org/access/tencommandments.htm

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

Similar Threads

  1. Replies: 3
    Last Post: 01-02-2014, 08:11 AM
  2. Replies: 1
    Last Post: 08-24-2012, 07:11 AM
  3. Replies: 1
    Last Post: 11-25-2011, 11:16 AM
  4. Replies: 2
    Last Post: 03-21-2011, 12:55 PM
  5. lookup values in backend tables
    By deb56 in forum Database Design
    Replies: 1
    Last Post: 01-23-2008, 11:12 AM

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