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

    Updating a table using VBA


    My database will save excel files on a network location (to save space in the database). I've created a maintenance table that will allow the administrator to change the network location where the excel files will be saved. But am getting a syntax error. The code is supposed to save the file path and name in a maintenance table. See below.

    Code:
    Private Sub cmdQALocation_Click()
    ' This code will open a file dialog box and allow administrator to select the location for the QA Master File
    ' The QA Master file must be in excel format
    
    Dim fd As FileDialog
    Dim objfl As Variant
    Dim strQAFileLocation As String
    
        Set fd = Application.FileDialog(msoFileDialogFilePicker)
        With fd
            .ButtonName = "Select"
            .AllowMultiSelect = False
            .Filters.Add "xlsx", "*.xlsx"
            .Filters.Add "xlsm", "*.xlsm"
            .Filters.Add "xls", "*.xls"
            .Title = "Choose Quality Alert Master File"
            .InitialView = msoFileDialogViewDetails
            .Show
            For Each objfl In .SelectedItems
                strQAFileLocation = objfl
            Next objfl
            On Error GoTo 0
        End With
    
        Set fd = Nothing
    
        DoCmd.RunSQL "UPDATE tblMaintenance SET QA_Location = " & strQAFileLocation & "  WHERE ID = 1"
    
    End Sub
    Any Help would be appreciated!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    The QA_Location is a text field. Values for text field need apostrophe delimiters.

    DoCmd.RunSQL "UPDATE tblMaintenance SET QA_Location = '" & strQAFileLocation & "' WHERE ID = 1"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-19-2013, 07:22 PM
  2. Updating main table from temp table AND form value
    By shabbaranks in forum Programming
    Replies: 8
    Last Post: 05-01-2013, 07:18 AM
  3. Replies: 2
    Last Post: 03-13-2013, 06:30 AM
  4. Replies: 6
    Last Post: 05-10-2012, 08:20 PM
  5. Replies: 0
    Last Post: 03-27-2011, 02:05 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