Results 1 to 2 of 2
  1. #1
    crimedog is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2013
    Posts
    141

    Use check Boxes on form to determine which fields to update

    I have uploaded an Excel file with updated info into TempTableExcel... Created Update Query that uses TempTableEcel to update MainTbl Work great.
    Now: can I create a form that lets the users update ONLY specific fields
    Say Date has not changed BUT Note has OR Note has not changed but Date has (for MANY rows)



    I add a check box for Date and for Note on form Frm_ChooseUpdate check one or both boxes - click BtnUpdate - Updates are made

    I am guessing there is some criteria I can add to the Update Query -
    Note : there are about 15 check boxes - so having Multiple Update Queries would be cumbersome


    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Build sql by checking all checkboxes:
    Code:
    Public Sub btnUpdateFlds_Click()
    Dim sSql As String
    dim vUpd
        'the query is built depending on the various filters the user picks...
    If  chkState Then vUpd = vUpd & " [state]='" & cboState & "',"
    If chkName Then vUpd = vUpd & " [Name]='" & txtName & "',"
    If chkContact Then vUpd = vUpd & " [Contact]=" & chkContact.Value & ","
    
    'remove last comma
    vUpd = left(vUpd, len(vUpd)-1)
    
    sSql = "update table set " & vUpd
    
    docmd.setwarnings false
    docmd.runSql sSql
    docmd.setwarnings true
    End Sub
    Last edited by ranman256; 01-25-2020 at 06:41 AM.

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

Similar Threads

  1. Check Boxes linked to Date Fields on a Form
    By WILTSBOY in forum Forms
    Replies: 10
    Last Post: 04-25-2017, 10:16 AM
  2. Replies: 6
    Last Post: 05-10-2012, 10:32 AM
  3. yes/no fields as check boxes
    By mejia.j88 in forum Reports
    Replies: 6
    Last Post: 01-30-2012, 10:01 AM
  4. Update Two fields (text boxes) Form
    By j2curtis64 in forum Forms
    Replies: 11
    Last Post: 07-06-2011, 08:43 AM
  5. How to Query fields with check boxes?
    By JynxRD in forum Queries
    Replies: 2
    Last Post: 09-10-2010, 08:35 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