Results 1 to 5 of 5
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Assigning values to Text Boxes

    I have a string of values that I am extracting from a table ("1,2,5"). I also have 9 check boxes on a form. When the user loads the form I want to automatically "check" the checkbox that corresponds to the values in the string...see example

    on load

    StringValue = "1,4,5"


    chk1, chk4, chk5 value = true
    chk2, chk3, chk6, chk7, chk8, chk9 value = false

    I am able to extract the string using DLookup() and split the string. My difficulty is getting the corresponding check-box assigned the true value. This can be a variable selection of any combination.

    This is what I tried but it obviously didn't work
    Code:
    Const DenSelect As String = "1,4,5" 'This will be DLookup() in actual code
    Dim strSelect() As String
    Dim intCounter As Integer
    strSelect = Split(DenSelect, ",")
    For intCounter = LBound(strSelect()) To UBound(strSelect())
        chkreason & strpart(intcounter).value = -1
    '    MsgBox strSelect(intCounter)
    Next intCounter

  2. #2
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Sorry..Title should be "Assigning values to Check Boxes" not "Assigning values to Text Boxes".

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Const DenSelect As String = "1,4,5" 'This will be DLookup() in actual code
    chk1.checked=instr(1,denSelect,"1")>0
    chk2.checked=instr(1,denSelect,"2")>0
    chk3.checked=instr(1,denSelect,"3")>0
    chk4.checked=instr(1,denSelect,"4")>0
    chk5.checked=instr(1,denSelect,"5")>0
    chk6.checked=instr(1,denSelect,"6")>0
    chk7.checked=instr(1,denSelect,"7")>0
    chk8.checked=instr(1,denSelect,"8")>0
    chk9.checked=instr(1,denSelect,"9")>0

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Great. Thank you.

  5. #5
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Here is another option using looping - Check box controls must have common names. (http://www.mvps.org/access/forms/frm0003.htm)


    See attached zip (A2K format)

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

Similar Threads

  1. Replies: 10
    Last Post: 12-11-2010, 11:01 PM
  2. Replies: 11
    Last Post: 10-06-2010, 12:19 AM
  3. Replies: 1
    Last Post: 03-27-2010, 06:13 AM
  4. Assigning values to duplicate records
    By matteu1 in forum Queries
    Replies: 3
    Last Post: 02-17-2010, 10:35 PM
  5. Assigning Values/Scorecard
    By nicholali in forum Access
    Replies: 0
    Last Post: 11-17-2008, 03:20 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