Checkbox Problem

  • Thread starter Thread starter robboll
  • Start date Start date
R

robboll

Access 2003

I have a form with six paired checkboxes (for three events) A, B, and
C.

Event Start End

A --------- AS ----------- AE
B --------- BS ----------- BE
C --------- CS ----------- CE

And a Status textbox. The Status is either "Pending" or "Waiting"

When you open the form and all checkboxes are 0 the Status = "Pending"

If you check AS the Status changes to "Waiting" until AE is checked.
Then it changes back to "Pending"

The same thing applies to B and C.

My code below seems to work if you move from A to C, but moving up it
doesn't work.

Any time a Start is checked and and an End is unchecked, the Status
should be Waiting.

I think theres a much easier way to do this:

Function Stat()

'A ---------------
If Forms!frmStatus!ASD = -1 And Forms!frmStatus!AE = 0 Then
Forms!frmStatus!txtSTATUS = "Waiting"
End If

If Forms!frmStatus!ASD = -1 And Forms!frmStatus!AE = -1 Then
Forms!frmStatus!txtSTATUS = "Pending"
End If

'B ----------------
If Forms!frmStatus!BSD = -1 And Forms!frmStatus!BE = 0 Then
Forms!frmStatus!txtSTATUS = "Waiting"
End If

If Forms!frmStatus!BSD = -1 And Forms!frmStatus!BE = -1 Then
Forms!frmStatus!txtSTATUS = "Pending"
End If
'C -----------------
If Forms!frmStatus!CSD = -1 And Forms!frmStatus!CE = 0 Then
Forms!frmStatus!txtSTATUS = "Waiting"
End If

If Forms!frmStatus!CSD = -1 And Forms!frmStatus!CE = -1 Then
Forms!frmStatus!txtSTATUS = "Pending"
End If

End Function


Any help with this greatly appreciated!

RBollinger
 
robboll said:
Access 2003

I have a form with six paired checkboxes (for three events) A, B, and
C.

Event Start End

A --------- AS ----------- AE
B --------- BS ----------- BE
C --------- CS ----------- CE

And a Status textbox. The Status is either "Pending" or "Waiting"

When you open the form and all checkboxes are 0 the Status = "Pending"

If you check AS the Status changes to "Waiting" until AE is checked.
Then it changes back to "Pending"

The same thing applies to B and C.

My code below seems to work if you move from A to C, but moving up it
doesn't work.

Any time a Start is checked and and an End is unchecked, the Status
should be Waiting.

I think theres a much easier way to do this:

Function Stat()
Your way just didn't change things back if something was unchecked.
I changed to True and False to make things clearer (at least for me)
This is untested and may need some lines swapped but the method is good.

'A ---------------
If Forms!frmStatus!ASD = True then
If Forms!frmStatus!AE = FalseThen
Forms!frmStatus!txtSTATUS = "Waiting"
Else ' Change it back if it was
already checked.
Forms!frmStatus!txtSTATUS = "Pending"
End If
Else 'Change it back if it was checked.
Forms!frmStatus!txtSTATUS = "Pending"
 
I have had a look at this and I think one would need to know the rules for
checking the boxes. For example, is it allowable to skip a box. Like check
ASD, not check AE and then check BSD.
 
Back
Top