Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / September 2006

Tip: Looking for answers? Try searching our database.

Using "Between" in VB Script

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jennifer Cali - 16 Sep 2006 22:58 GMT
I have a text box that the users enter a number between 1 and 10. If the
enter a number between 1 and 5, I want a yellow box to appear; if between 6
and 10, I want a blue box to appear.  I've been able to code it partially but
don't know how to make the range included (if between 6 and 10 then), etc.
What I have so far is listed below - thank you!!!

Private Sub Text8_AfterUpdate()

If Text8 = "0" Then
Me.Controls(Yellow.Name).Visible = False
Me.Controls(Blue.Name).Visible = False
Else
Me.Controls(Yellow.Name).Visible = True
Me.Controls(Blue.Name).Visible = False
ELSe
Me.Controls(Yellow.Name).Visible = False
Me.Controls(Blue.Name).Visible = True

End If

End Sub

Signature

Thank you! - Jennifer

david@epsomdotcomdotau - 17 Sep 2006 00:14 GMT
if text8 = 0 then

elseif text8 < 6 then

else

endif

(david)

> I have a text box that the users enter a number between 1 and 10. If the
> enter a number between 1 and 5, I want a yellow box to appear; if between 6
[quoted text clipped - 17 lines]
>
> End Sub
Jennifer Cali - 17 Sep 2006 06:28 GMT
David, I'm doing something wrong because no matter what number I insert
(besides zero) only the blue box shows up - I never see the black one. Even
if I enter 8 or 9 - which are definitely greater than 6 - I still don't see
the black; just blue:

Private Sub Text8_AfterUpdate()

If Text8 = "0" Then
Me.Controls(RShoulderBlue.Name).Visible = False
Me.Controls(RShoulderBlack.Name).Visible = False
ElseIf Text10 < 6 Then
Me.Controls(RShoulderBlack.Name).Visible = False
Me.Controls(RShoulderBlue.Name).Visible = True
ElseIf Text10 > 6 Then
Me.Controls(RShoulderBlack.Name).Visible = True
Me.Controls(RShoulderBlue.Name).Visible = False
End If
End Sub
Signature

Thank you! - Jennifer

> if text8 = 0 then
>
[quoted text clipped - 29 lines]
> >
> > End Sub
david@epsomdotcomdotau - 17 Sep 2006 10:51 GMT
Your first question was about Text8.
I see that your new question is about Text8 and Text10.
Is that a mistake?

(david)

> David, I'm doing something wrong because no matter what number I insert
> (besides zero) only the blue box shows up - I never see the black one. Even
[quoted text clipped - 48 lines]
> > >
> > > End Sub
Jennifer Cali - 17 Sep 2006 17:44 GMT
YES!!! It is a mistake - I goofed and it should all be for the Text8. I've
changed the code but now have another snag (I seem to be full of them today).
It seems to be coding at a higher level than I want it to. If I create
multiple records, then the change take place for the most-recently updated
record.

What I'm showing is a figure of the right arm. Each record contains several
Pain Index fields, representing the palm, fingers, wrist, forearm, etc. By
entering a number up to 6, a blue box appears over the pain area. If greater
than 6, a black box appears (more severe pain). However, now when I enter an
"8" in the wrist box for record #1, all subsequent records show a black box
over the wrist even if they have a value of 0 or 2. I need this to be RECORD
specific...I hope this makes sense.

---
Thank you! - Jennifer

> Your first question was about Text8.
> I see that your new question is about Text8 and Text10.
[quoted text clipped - 63 lines]
> > > >
> > > > End Sub
Jennifer Cali - 17 Sep 2006 17:54 GMT
I think what I need to do is set the control source of the actual square,
right? So the blue square's control source would be something like: Iif(Text8
= 0, Visible = False, Iif(Text8 < 6, Visible = True, Iif (Text8 > 6, Visible
= False))).

My example above (obviously) doesn't work...but is this close? What do I
need to do to fix?
Signature

Thank you! - Jennifer

> YES!!! It is a mistake - I goofed and it should all be for the Text8. I've
> changed the code but now have another snag (I seem to be full of them today).
[quoted text clipped - 80 lines]
> > > > >
> > > > > End Sub
David Cox - 17 Sep 2006 19:43 GMT
from a rusty, unreliable memory, and untested:

bluecontrol.visible = ([Text8]>0) And ([Text8]<=6)

([Text8]>0) and other such logical expressions resolves to True or False.
True And True resolves to True,
True And False resolves to False

The IF  ... Else statements, although more verbose, also work and are easier
for most to read.

>I think what I need to do is set the control source of the actual square,
> right? So the blue square's control source would be something like:
[quoted text clipped - 104 lines]
>> > > > >
>> > > > > End Sub
Jennifer Cali - 17 Sep 2006 20:12 GMT
Hi David,
You're great - I've almost got it. I've created a text box (set background
to blue) and inserted the following code into the control source:

=[Text17].[Visible]=([Text8]>0) And ([Text8]<=6)

However, while there is no error, the text box always shows and displays -1
(if the value is true) and 0 (if the value is false). I feel like we're so
close...

Signature

Thank you! - Jennifer

> from a rusty, unreliable memory, and untested:
>
[quoted text clipped - 115 lines]
> >> > > > >
> >> > > > > End Sub
David Cox - 17 Sep 2006 21:08 GMT
I read your code:
> > Iif(Text8
> > = 0, Visible = False, Iif(Text8 < 6, Visible = True, Iif (Text8 > 6,
> > Visible
> > = False))).

I thought you were trying to make the blue box visible in one case and
invisible in the other, which was why I had the control.visible  syntax.

I do not understand why you think you want to set control source.

>> >> What I'm showing is a figure of the right arm. Each record contains
>> >> several
[quoted text clipped - 4 lines]
>> >> greater
>> >> than 6, a black box appears (more severe pain).

I could have had something like:
Blackbox.visible = ([Text8] > 6)
Bluebox.visible = ([Text8]>0) And ([Text8]<=6)

except that I would want colored pictures of the various body parts in their
close to correct positions.

> Hi David,
> You're great - I've almost got it. I've created a text box (set background
[quoted text clipped - 136 lines]
>> >> > > > >
>> >> > > > > End Sub
chris.nebinger@gmail.com - 18 Sep 2006 16:34 GMT
As an alternative, you could use Conditional Formatting.  Right click
on the field in design view, then select Conditional Formatting.  The
rest should be pretty self explanatory.

Chris Nebinger.

> I read your code:
> > > Iif(Text8
[quoted text clipped - 173 lines]
> >> >> > > > > --
> >> >> > > > > Thank you! - Jennifer
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.