dbTalk Databases Forums  

If...Then...Else

comp.database.ms-access comp.database.ms-access


Discuss If...Then...Else in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
GMKS
 
Posts: n/a

Default If...Then...Else - 02-16-2004 , 04:41 PM






Hello all,

I have 13 check boxes on a form.

I am trying to check all the check boxes to determine if they are true or false when I close the form.

At present only the first IF...Then...Else works and then Exits the Sub.

Example:

If Me.First = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If

If Me.Second = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If

If Me.Third = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If
....
Total of 13 check Boxes to be checked on Form Close.

I have tried with only one End If statement at the end to no luck.

Thank you for your help.

Glen




Reply With Quote
  #2  
Old   
Bruce Pick
 
Posts: n/a

Default Re: If...Then...Else - 02-19-2004 , 09:30 PM






I would try these alternatives to your original
If Me.First = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If

I think you're tempting trouble to find you
by using the ":" to get a single line.

1)
If Me.First = True Then
Me.FieldName = "Yes"
Else
Me.FieldName = "No"
End If

2)
If Me.First = True Then
Me.FieldName = -1
Else
Me.FieldName = 0
End If

3) If Me.First = True Then
Me.FieldName = True
Else
Me.FieldName = False
End If

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++
To send email, remove all < > and [ ] and the junk ~ between:
[brucepick1]
< a~t >
[comcast.net]


GMKS wrote:
Quote:
Hello all,

I have 13 check boxes on a form.

I am trying to check all the check boxes to determine if they are true
or false when I close the form.

At present only the first IF...Then...Else works and then Exits the Sub.

Example:

If Me.First = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If

If Me.Second = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If

If Me.Third = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If
...
Total of 13 check Boxes to be checked on Form Close.

I have tried with only one End If statement at the end to no luck.

Thank you for your help.

Glen



Reply With Quote
  #3  
Old   
Bruce Pick
 
Posts: n/a

Default Re: If...Then...Else - 02-20-2004 , 08:45 AM



Oh, I didn't catch this -

If your text boxes are named "First", Second", etc, you should code as
If Me!First = True Then

Using ! instead of . for all references to form controls.

Someone wrote that Access is pretty forgiving when using the wrong
separator, but maybe not always.

If your controls are named the same as the field names, you should
change them, say to txtFieldName, so there is never any confusion as to
whether you're referencing the control or the field in the data source.

I usually rename any such control before referencing it in VBA code. If
never referencing it, I'm content to leave the name alone. Access puts
in those copied names when you drag a field in from the field list. If
you build it manually from the Toolbox, it gives it a name like "Text28".

Bruce Pick
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++
To send email, remove all < > and [ ] and the junk ~ between:
[brucepick1]
< a~t >
[comcast.net]


GMKS wrote:
Quote:
Hello all,

I have 13 check boxes on a form.

I am trying to check all the check boxes to determine if they are true
or false when I close the form.

At present only the first IF...Then...Else works and then Exits the Sub.

Example:

If Me.First = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If

If Me.Second = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If

If Me.Third = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If
...
Total of 13 check Boxes to be checked on Form Close.

I have tried with only one End If statement at the end to no luck.

Thank you for your help.

Glen



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.