Take the tour ×

I am building a report in access 2007, and trying to set a checkbox to true based on the value of a string in a textbox. For example: If txtBoxValue = "Injury" then chkBoxValue = True(Checked) Else chkBoxValue = False(unchecked).

This is the value I have in the source control of chkBoxValue.


I am new to VBA, and any help would be appreciated.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

This should work as the control source of chkBoxValue:


Be careful about the quotes you use in VBA code. Notice you used ” (ASCII 148) and I used " (ASCII 34).

Edit: As @nicholas pointed out, that control source expression will give you Null when [txtBoxValue] is Null. If you prefer False instead, add the Nz() function.

share|improve this answer
This expression can lead to a tri-state checkbox. If the value for [txtBoxValue] is null, the checkbox will be neither checked nor unchecked - it will be shaded gray. –  nicholas Jun 7 '12 at 14:24
add comment

True / False fields use values -1 and 0 in Access. You also have constants TRUE and FALSE.

The control source of the checkbox should read:

share|improve this answer
I don't think that will work with single quotes. The db engine will accept single quotes, but the control source is VBA which requires double quotes and the db engine is not involved. –  HansUp Jun 6 '12 at 22:52
This may be true. If the field is defined in Report Designer view or the expression is defined in Expression builder, single quotes are sufficient. However, double quotes will always work, so I changed it as suggested. –  nicholas Jun 7 '12 at 0:25
add comment

Your Answer


