473,471 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

when to quote variable values?

Is there a rule of thumb for quoting variable values? For example, do I
have to put all string number values in quotes?

strAbc = "3" ?

What about long, int and byte? I assume these are NOT supposed to be quoted

lngID = 4

How about values I get from an unbound textbox?

Me!txtFs = 5 --or-- Me!txtFs = "5"

and what about when using Select Case?

Select Case Me!tabMain
Case 0
Case 1
End Select

--or--

Select Case Me!tabMain
Case "0"
Case "1"
End Select

??
Nov 12 '05 #1
8 1982
This is an important question. You must get the data type correct for Access
to understand your query/code correctly.

For fields, do not use any delimiter for the Number or Currency type fields,
e.g.:
WHERE MyNumber = 9999

Use quote marks as delimiters around text values, e.g.:
WHERE MyText = "xxxx" OR MyText = "9999"

Use # as the delimiter around date values, e.g.
WHERE InvoiceDate = #1/4/2004#

In code, use the corrrect data type. The Value of a tab control is always an
integer, so you would use:
If Me.tabClt0 = 0 Then

You can find the data type by asking Access to give you the typename:
? TypeName(Forms!Form1!TabClt0.Value)

Access type-casts automatically, so it often changes the types to whatever
you need without telling you. In my view, this makes it harder to learn and
understand what is going on, and frequently results in code and queries that
do not work as intended. More info and exmamples:
http://allenbrowne.com/ser-45.html

Regarding your specific question about Select Case with a tab control, this
is probably best as it still works even if you reorder the pages of the tab
control, and it generates a suitable error if you remove or rename pages:
Select Case Me.TabClt0
Case Me.Page1.PageIndex
Case Me.Pagexxx.PageIndex


--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"deko" <dj****@hotmail.com> wrote in message
news:EJ**************@newssvr29.news.prodigy.com.. .
Is there a rule of thumb for quoting variable values? For example, do I
have to put all string number values in quotes?

strAbc = "3" ?

What about long, int and byte? I assume these are NOT supposed to be quoted
lngID = 4

How about values I get from an unbound textbox?

Me!txtFs = 5 --or-- Me!txtFs = "5"

and what about when using Select Case?

Select Case Me!tabMain
Case 0
Case 1
End Select

--or--

Select Case Me!tabMain
Case "0"
Case "1"
End Select

??

Nov 12 '05 #2
The only time you need to use quotes is when the variables needs a string
value.

In the case of un-bound textbox, you should still follow some convention.

If the values in the un-bound text box are fact strings,a nd NOT just
numbers, then in your code, you should use quotes. The reason is that the
text box will take on whatever data type you assign to it. So, if your code
expects strings, then use quotes.

Further, when reading code.

me!SomeTextBox = "12"

or

me!SomeTextBox = 12

Both of the above will work, but as a developer reading the above code, it
is clear that the first example assumes that the text box can have all kinds
of characters, since it would be silly for the developer to use quotes when
you need a number. And, of course, the reverse is true for the 2nd value.
So, YOU get to decide if you need quotes in the above. If that control is
only supposed to have numbers, then you should not use strings, and should
not use quotes, but just use a number.

What about long, int and byte? I assume these are NOT supposed to be quoted
lngID = 4
The above sounds correct to me.

How about values I get from an unbound textbox?

Me!txtFs = 5 --or-- Me!txtFs = "5"
Well, in the above, you not getting values...but in fact putting in values!
However, ignoring the above minor context mistake, the notes I mention above
still apply.
and what about when using Select Case?

Select Case Me!tabMain
Case 0
Case 1
End Select


Well, it depends on what type of values the tabMain expects. If you are
storing string values into tabMain, the you would use quotes. If you are
storing numbers, then you would NOT use quotes.

So, the answer will depend on what you as the designer needs to store in
that field. In the above example it does look like tabMain is a number value
from a tab control, and thus you of course would use numbers.
--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
No************@msn.com
http://www.attcanada.net/~kallal.msn

Nov 12 '05 #3
hi,
i recall quite awhile back you were asking for games created with access,
if you are still curious i have a dinky horse racing game, its ok but the
odds are entirely bogus. if you want i a can upload it to a page and give
you the link - A97, but it runs fine on AXP, havent tried it on A2K.
later,
dingus
Nov 12 '05 #4
"deko" <dj****@hotmail.com> wrote in message news:<EJ**************@newssvr29.news.prodigy.com> ...
Is there a rule of thumb for quoting variable values? For example, do I
have to put all string number values in quotes?


Real simple. If it's a string value that you're assigning to a
variable, then use quotes.

Dim strWhatever As String
strWhatever = "Something"

Dim dtDate as Date
dtDate = #5/1/2004#

If the field is formatted for the variable type you're using then you
can use

strWhatever = Me!txtWhatever

Numbers - no quotes.
Nov 12 '05 #5
"deko" <dj****@hotmail.com> wrote in message news:<EJ**************@newssvr29.news.prodigy.com> ...
Is there a rule of thumb for quoting variable values? For example, do I
have to put all string number values in quotes?


Real simple. If it's a string value that you're assigning to a
variable, then use quotes.

Dim strWhatever As String
strWhatever = "Something"

Dim dtDate as Date
dtDate = #5/1/2004#

If the field is formatted for the variable type you're using then you
can use

strWhatever = Me!txtWhatever
Nov 12 '05 #6
dingusmcgee <di**********@yahoo.com> wrote:
i recall quite awhile back you were asking for games created with access,
if you are still curious i have a dinky horse racing game, its ok but the
odds are entirely bogus. if you want i a can upload it to a page and give
you the link - A97, but it runs fine on AXP, havent tried it on A2K.


Someone else I know created Frogger game, with jumping frog and moving vehicles, and
the Tower of Hanoi puzzle.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 12 '05 #7
In fact, every year around the Christmas holidays, I being to think my of
quest to create a VERY nice looking game of pong for ms-access. (and
multi-user to boot!). Breakout would also be good.

This year, I had way too much fun during the holidays, and did not do my
usual huge eat pizza and drink gallons of pop to write some cool code thing.
I used to love doing that during the holiday season, and this year that did
not happen!

Gee, I hope I am not getting old!

So, as it stands, thank you kindly, but nope...not looking for games just
yet, and ones that I do look for should be faithful reproductions of
classics (pong, packMan etc).
--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
No************@msn.com
http://www.attcanada.net/~kallal.msn
Nov 12 '05 #8
One of my favourite gifts this year was the Atari Classic 10 games. All
of the games are embedded in a slightly oversized joystick with video
and audio outputs directly to your TV. THis is the original code. My
daughter likes Pong but my favourite is Missile COmmand. I cannot
believe that I still remember the sournds and screen colors for each
level so well from 20 years ago!
:-)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Albert D. Kallal" <pl********************@msn.com> wrote in message
news:VA0Lb.18265$X%5.8213@pd7tw2no...
In fact, every year around the Christmas holidays, I being to think my of quest to create a VERY nice looking game of pong for ms-access. (and
multi-user to boot!). Breakout would also be good.

This year, I had way too much fun during the holidays, and did not do my usual huge eat pizza and drink gallons of pop to write some cool code thing. I used to love doing that during the holiday season, and this year that did not happen!

Gee, I hope I am not getting old!

So, as it stands, thank you kindly, but nope...not looking for games just yet, and ones that I do look for should be faithful reproductions of
classics (pong, packMan etc).
--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
No************@msn.com
http://www.attcanada.net/~kallal.msn


Nov 12 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Simon | last post by:
Hi, I have written an ActiveX object to resize images and upload them to a database, this all works fine but when I close internet explorer the process iexporer.exe is still running in my task...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
12
by: John Henry | last post by:
Hi list, Just to make sure I understand this. Since there is no "pointer" type in Python, I like to know how I do that. For instance, if I do: ...some_huge_list is a huge list...
23
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of...
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
7
by: alfred.fazio | last post by:
Hello everybody, I've banged my ahead around for a while trying to figure out why multiple instances of a class share the same instance variable. I've stripped down my code to the following,...
0
by: raylopez99 | last post by:
I ran afoul of this Compiler error CS1612 recently, when trying to modify a Point, which I had made have a property. It's pointless to do this (initially it will compile, but you'll run into...
4
by: tiago.private | last post by:
Hi everybody, Imagine the following scenario: One System.Web.UI.UserControl (UC1) with 2 drop downs and one button "Filter" One Webform with (UC1) and a GridView, basically the UC1 provides...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.