expressions....

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello there
i have three fields (yes/no)...i was wondering if there is a way, the one of
them turns yes when the other two are yes, and the opposite. i was looking on
the expression builder in microsoft but i didnt found something so far...
thanks
 
1. Create 3 check boxes on a form
Name: Check1
Name: Check2
Name: Check3

2. Assign a default value of "False" to all 3.

3. In the AfterUpdate() event of Check1, add this code:

Private Sub Check1_AfterUpdate()

Me.Check2.Value = Not Me.Check2.Value
Me.Check3.Value = Not Me.Check3.Value

End Sub

Whenever the Checkbox for 1 is selected, it will turn the other 2 the
opposite.

HTH

Rob Mastrostefano

--
FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com
 
im very sorry for asking u again but i didnt express my thought very well
before my english r terrible ...

im was thinking something like that:
check1 check2 check 3
no no --->yes
no yes --->yes
yes no ---->yes
yes yes --->no

if u can help me with this ...thanks again
 
Ok... If I'm understanding correctly, you want to evaluate check1 and check2
and based on those results, you want to automatically have check3 set?

Let me know and then I can write out the code you need.

Rob Mastrostefano

--
FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com
 
When you have a mutually exclusive choice, you should store a single field
rather than three separate fields and you should use an option group to
display the choices except when there are a lot of them. In that case, you
would use a combo.
 
yes exactly that....the only time the last <check button> turns <off> is
when all the other are <on> . in any other situation the last button is
<on>...
now im making experiments with 3 button but in my db i will use more...
if u can help me that would be great....


Ο χÏήστης "RobFMS" έγγÏαψε:
 
the many buttons correspond to partial works and the last one for
pendency...so the last one has to be uncheck only all the others are
checked...i didnt find any other way to do this..

Ο χÏήστης "Pat Hartman(MVP)" έγγÏαψε:
 
Don't forget to keep the default values for each of the check boxes.

Here's the code.

Rob Mastrostefano



Private Sub Check1_AfterUpdate()

Me.Check3.Value = SetCheck3(Me.Check1.Value, Me.Check2.Value)

End Sub

Private Sub Check2_AfterUpdate()

Me.Check3.Value = SetCheck3(Me.Check1.Value, Me.Check2.Value)

End Sub

Public Function SetCheck3( _
ByVal fCheck1 As Boolean, _
ByVal fCheck2 As Boolean) As Boolean

' Check1 Check2 | Check3
' -----------------------------
' no no | yes
' no yes | yes
' yes no | yes
' yes yes | no

Dim fReturnValue As Boolean

Select Case True
Case (fCheck1) And (fCheck2)
fReturnValue = False
Case Else
fReturnValue = True
End Select

SetCheck3 = fReturnValue

End Function


--
FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com
 
the third section with the< public function..>start , where is it fit ? :)

i have no idea about that vb code but i guess, bulding one for six or
seven button must be chaos..
thanks for your spend time!!

Ο χÏήστης "RobFMS" έγγÏαψε:
 
Back
Top