Results 1 to 2 of 2

Thread: [Access] Help for assigning checkbox to a recordset value?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    29

    [Access] Help for assigning checkbox to a recordset value?

    Code:
    Private Sub Command13_Click()
    
    Dim abc as string
    
    abc = Combo10.Value
    …
    …
    …
    forms!abc.Check1 = rst![name]    ‘assign check1 to one recordset value
    
    DoCmd.OpenForm abc, acNormal
    
    
    End Sub
    This command 13 button will open a form according to the combo10.value which the user chooses. I have many different forms’ names assigned to combo10.

    There is an error when I run the above code because the forms!abc.check1 has an error.
    This is because access cannot read the different forms names under abc.

    Is there another way for forms!abc.Check1 to work when the forms names under abc will change?

    Thanks.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: [Access] Help for assigning checkbox to a recordset value?

    1) rename your controls!! and use a naming convention


    2)
    cboForms can be a 2 column list. 1st column is hidden and holds the actual form name (again use a naming convention) - this is invisible (width of 0). The second column is the name to display

    Combo columns in Access/excel start at 0.

    Your code would change to:

    Code:
    strForm = cboForms.column(1)
    forms(strForm).controls("controlname") = rst("fieldname")
    if you are in access you can also use the function nz (replaces null values with a value) and use this nz function around the recordset field eg
    Code:
    nz(recordset("fieldname"),false)

    See if that helps?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width