How to (Functions)

E

Ellen

Hello, I am really dumb at this and really want to learn
how to use these functions, I have read and studied,
however not getting it. Can someone give me examples of
how to use these following functions, I know it is asking
alot, but here we go. Thank You.

LCASE(), Left(), Len(), Mid(), Right(), RTrim(),
Space(), TrimS(), UCase(), DateAdd(), DateDiff(), Avg
(), Count(), Max(), Min(), SumS().

I am tring to teach my self Access, I have used the help
feature, still not understanding.
 
M

Michel Walsh

Hi,


You can try them on the Immediate Debug Window. Cut and paste the next
indented line, one by one, into the Access Immediate (Debug) Window, and
make a return to see the result.


Debug.Print LCASE("Hello World")

should return the string into all Lower CASE characters.


Debug.Print Left("Hello World", 5)

should return the fifth first characters ( at the left of ) the string.

Debug.Print Mid("Hello World", 4, 5 )

should return 5 characters from the fourth one. If you do not supply the
third argument, the length of the result to be returned, the result goes "up
to" the end of the string:

Debug.Print Mid("Hello World", 4)

Debug.Print RIght("Hello World", 2)

should return the 2 last (rightmost) characters.

Debug.Print len("Hello world")

should return the number (len_gth) in the string.

Debug.Print len(RTrim("Hello world "))

should return the length of the string from which we have trimmed (removed)
the spaces at the Right.


Debug.Print "*" & Space(5) & "*"

should return five spaces embedded by a * at each end.

Debug.Print "*" & Trim( " Hello World ") & "*"

should show you that trim remove spaces at the left and at the right (but
not at the middle) of the string.


Debug.Print UCase("hello WoRlD")

should convert all character to upper case.


Debug.Print DateAdd("m", 2, Now( ) )

should show 2 months past now (we add 2 months to Now). See help file to
know how to add year, day, hour, minute, or second.)


Debug.Print DateDiff("m", #31-10-2004#, #11-1-2004# )

should give the number of different month change between the two given
dates. Here, 1, since we have change month one time from the 31 October to
the First of November. Again, see help file for other time interval.

Avg, Count, Max, Min and Sum are aggregate to be used in SQL, they operate
vertically, on one column. Sum( ColumnName ) would return the sum of the
values in the mentionned field name. Avg would average, Max would find the
maximum; Min, the minimum and Count( fieldName ) will count the number of
time a record has a not null value. Count(*) would count the number of
records.



Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top