Checkbox based on & updating a text field

naomi1017

New member
Local time
Today, 10:36
Joined
Jul 18, 2012
Messages
7
My database has a text field "Status" where the text is either, A, W, C. There is a form to update this field; currently it uses a standard Access created text field. The users want a checkbox which will show up as checked when the status is W, if the status is anything else, the checkbox will be blank. If the user clicks the checkbox within the form the status will be changed to W.

In my head this is pretty simple.

If [table.status] = 'W'
then checkbox = 0
else
checkbox = -1

and then somewhere on the update it would be
if checkbox = -1 then [table.status] = R

Except that Access doesn't think the way I do. I'm stumped on how to make it work. Any thoughts?
 
Last edited:
Use the current event of a form to update data or UI elements that depend on values in the current record. If there is a status field in the current record you can do something like this ...
Code:
Private Sub Form_Current()
[COLOR="Green"]   'set the status checkbox False when Status <> "W"[/COLOR]
   Me.chkStatus = Not Me.Status = "W"
End Sub
... and then handle the Click or AfterUpdate events of the checkbox ...
Code:
Private Sub chkStatus_Click()
[COLOR="Green"]   'set the Status to "R" if the user sets the checkbox[/COLOR]
   If Me.chkStatus Then Me.Status = "R"
[COLOR="Green"]   'note that clearing the checkbox has no effect[/COLOR]
End Sub
 

Users who are viewing this thread

Back
Top Bottom