[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.
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?