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.
=IIf([txtBoxValue]=”Injury”,1,0)
I am new to VBA, and any help would be appreciated.
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 preferFalseinstead, add theNz()function.