Results 1 to 6 of 6
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    DAO Recordset Edit/Update


    While the compiler doesn't complain, execution fails not being able to recognize the table field name. chkBox is a string variable containing the table's field name. What's the proper syntax for the field assignment? (I tried with and without the brackets. Compiler fails without the brackets.)
    Code:
            rsCol1.Edit        
            rsCol1![ & chkbox & ] = True
            rsCol1.Update

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    You could use the Fields collection, then the simple chkbox should work?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    Not at my computer but to be brief

    rscol1.fields(me.chkbox)=true

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Sorry, you lost me with the "Me.chkbox". "Me" implies to me a form's control reference. The issue is with setting the value of a table field where "ChkBox" is a string variable containing the name of the field.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Do you mean a variation of what Ajax is suggesting? E.g., rscol1!.fields(chkbox)=true

    This doesn't work with or without the quotes.
    rsCol1!Fields("ChkBox") = True Meaning field not found.

    EDIT: Just needed a period, not a splat! rsCol1.Fields(ChkBox)

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Well it is not going to work with quotes is it?
    That just makes it a literal.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Update or Cancel Update without add new or edit?
    By d9pierce1 in forum Programming
    Replies: 16
    Last Post: 05-06-2019, 06:53 PM
  2. Replies: 5
    Last Post: 06-12-2015, 02:15 PM
  3. Recordset edit values in fields of each record
    By Ruegen in forum Programming
    Replies: 3
    Last Post: 03-17-2014, 04:36 PM
  4. Cumulative totals: Cannot edit a field in recordset
    By Persist in forum Programming
    Replies: 4
    Last Post: 03-11-2012, 06:38 PM
  5. Edit Data in Recordset
    By Bwilliamson in forum Programming
    Replies: 3
    Last Post: 05-12-2011, 08:29 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