PDA

View Full Version : [Access] Help for assigning checkbox to a recordset value?



spidermman
11-04-2008, 09:27 AM
Private Sub Command13_Click()
Dim abc as string

abc = Combo10.Value



forms!abc.Check1 = rst![name] ‘assign check1 to one recordset checkbox
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.

CreganTur
11-04-2008, 10:15 AM
You cannot assign a value to a checkbox object other than True (checked) or False (unchecked). Attempting to assign any other value to the checkbox is invalid and will result in an error.

From your code it looks like you are using the object's default names (Check1, Command13, etc). This is not best practice and is a bad idea! You should really give all of your objects unique names that describe the object's purpose. This will make it much easier to code if you come back to the project after a long time, since you won't have to manually scan through multiple objects looking for Label141.

spidermman
11-04-2008, 10:21 AM
sorry i am not clear in the firstpost...
i am assigning a checkbox to the checkbox in the recordset.

for each form, there is a checklist whereby the user will tick the checkbox against the procedure that has been completed. Afterwhich, the user will save the form.

When i reopen the form, i would assign the check1 in the saved form to the recordset value.

However the forms!abc.check1 does not work because the form names under abc are different when the user choose a different form to open.

Is there a way to reopen saved forms?