473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Mid vs. Mid$ and proper use if these functions!

Hey can anyone explain to me the difference between Mid and Mid$ ....i
notice sometimes when i a running the update query with Mid$ it tells
me that for example 3 records will be updated ( which in theory is the
right amount based on the example) however sometimes only two records
are updated! Also in the Mid function i am not specifying the last
argument because I need the remainder of the string

example Mid([field1], 4) i am doing this becasue i want everything
from the 4th character till the end of the string.....is this approach
ok...

please advise
nawab
Nov 12 '05 #1
6 27570
The difference between the functions with the $ and those without is how
they handle Nulls. The ones with the $ are text only and will give you an
error if you pass them a Null.

As for your second question, if it does what you want it's ok.

--
Wayne Morgan
Microsoft Access MVP
"Nawab" <na******@hotmail.com> wrote in message
news:2b**************************@posting.google.c om...
Hey can anyone explain to me the difference between Mid and Mid$ ....i
notice sometimes when i a running the update query with Mid$ it tells
me that for example 3 records will be updated ( which in theory is the
right amount based on the example) however sometimes only two records
are updated! Also in the Mid function i am not specifying the last
argument because I need the remainder of the string

example Mid([field1], 4) i am doing this becasue i want everything
from the 4th character till the end of the string.....is this approach
ok...

please advise
nawab

Nov 12 '05 #2
Mid$() returns a String Variable.
Mid() returns a Variant.

Mid$() will be more efficient when working with strings in VBA code.

Mid() is the only choice when working with fields, because a field might be
Null and strings cannot be Null.

--
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.

"Nawab" <na******@hotmail.com> wrote in message
news:2b**************************@posting.google.c om...
Hey can anyone explain to me the difference between Mid and Mid$ ....i
notice sometimes when i a running the update query with Mid$ it tells
me that for example 3 records will be updated ( which in theory is the
right amount based on the example) however sometimes only two records
are updated! Also in the Mid function i am not specifying the last
argument because I need the remainder of the string

example Mid([field1], 4) i am doing this becasue i want everything
from the 4th character till the end of the string.....is this approach
ok...

please advise
nawab

Nov 12 '05 #3
thanks for your reply....although.....still not sure which func to
use...u say the Mid$ is text only.....that means alphanumeric is ok
but no special character like !#@ etc.....is that
correct....secondly....when im doing an update it tells me im about to
update 3 records in my table...which is the correct amount....but when
i go to the table it is only updating two records....please advise....

regards
nawab


"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<kc*******************@newssvr31.news.prodigy .com>...
The difference between the functions with the $ and those without is how
they handle Nulls. The ones with the $ are text only and will give you an
error if you pass them a Null.

As for your second question, if it does what you want it's ok.

--
Wayne Morgan
Microsoft Access MVP
"Nawab" <na******@hotmail.com> wrote in message
news:2b**************************@posting.google.c om...
Hey can anyone explain to me the difference between Mid and Mid$ ....i
notice sometimes when i a running the update query with Mid$ it tells
me that for example 3 records will be updated ( which in theory is the
right amount based on the example) however sometimes only two records
are updated! Also in the Mid function i am not specifying the last
argument because I need the remainder of the string

example Mid([field1], 4) i am doing this becasue i want everything
from the 4th character till the end of the string.....is this approach
ok...

please advise
nawab

Nov 12 '05 #4
i am still having this problem, when i am running a simple update
query in Access 2000 with Mid or Mid$ it tells me that 3 records will
be updated ( which in theory is the right amount) however most of the
time only two records
are updated! the expression i am using is

[field1]=Mid([field2],4)

does it matter which side of the = the Mid function lies...i ask
because i am simply doing an update where the above expression is
true...field1 and field2 are from two different tables...also i want
every character from the 4th position onwards, whereas the Mid
function requires a third arguement for number of characters(length)
to return, which i am excluding...becasue i want till end of
string....could that approach be why i am not getting every record
updated.....please someone help!

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<3f**********************@freenews.iinet.net. au>...
Mid$() returns a String Variable.
Mid() returns a Variant.

Mid$() will be more efficient when working with strings in VBA code.

Mid() is the only choice when working with fields, because a field might be
Null and strings cannot be Null.

--
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.

"Nawab" <na******@hotmail.com> wrote in message
news:2b**************************@posting.google.c om...
Hey can anyone explain to me the difference between Mid and Mid$ ....i
notice sometimes when i a running the update query with Mid$ it tells
me that for example 3 records will be updated ( which in theory is the
right amount based on the example) however sometimes only two records
are updated! Also in the Mid function i am not specifying the last
argument because I need the remainder of the string

example Mid([field1], 4) i am doing this becasue i want everything
from the 4th character till the end of the string.....is this approach
ok...

please advise
nawab

Nov 12 '05 #5
If you place this expression in the Update row of a query:
[field1]=Mid([field2],4)
Access evalues the expression as True or False.
If it's true, the value of your field updates to True.
If it's false, the value of your field updates to False.

If you intended to update Field1 to be everything from the 4th char of
Field2 onwards, remove the expression. Place this expression in the Update
row of Field1:
Mid([field2],4)

--
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.

"Nawab" <na******@hotmail.com> wrote in message
news:2b**************************@posting.google.c om...
i am still having this problem, when i am running a simple update
query in Access 2000 with Mid or Mid$ it tells me that 3 records will
be updated ( which in theory is the right amount) however most of the
time only two records
are updated! the expression i am using is

[field1]=Mid([field2],4)

does it matter which side of the = the Mid function lies...i ask
because i am simply doing an update where the above expression is
true...field1 and field2 are from two different tables...also i want
every character from the 4th position onwards, whereas the Mid
function requires a third arguement for number of characters(length)
to return, which i am excluding...becasue i want till end of
string....could that approach be why i am not getting every record
updated.....please someone help!

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message

news:<3f**********************@freenews.iinet.net. au>...
Mid$() returns a String Variable.
Mid() returns a Variant.

Mid$() will be more efficient when working with strings in VBA code.

Mid() is the only choice when working with fields, because a field might be Null and strings cannot be Null.

--
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.

"Nawab" <na******@hotmail.com> wrote in message
news:2b**************************@posting.google.c om...
Hey can anyone explain to me the difference between Mid and Mid$ ....i
notice sometimes when i a running the update query with Mid$ it tells
me that for example 3 records will be updated ( which in theory is the
right amount based on the example) however sometimes only two records
are updated! Also in the Mid function i am not specifying the last
argument because I need the remainder of the string

example Mid([field1], 4) i am doing this becasue i want everything
from the 4th character till the end of the string.....is this approach
ok...

please advise
nawab

Nov 12 '05 #6
na******@hotmail.com (Nawab) wrote in
news:2b**************************@posting.google.c om:
thanks for your reply....although.....still not sure which
func to use...u say the Mid$ is text only.....that means
alphanumeric is ok but no special character like !#@
etc.....is that correct....
Not correct. Mid$() returns a text value: any character that can
be created with the chr(n) function, given n is 1 to 255.

The Mid() function returns all those plus chr(0), the null
character.

secondly....when im doing an update it tells me im about to update 3 records in my table...which
is the correct amount....but when i go to the table it is only
updating two records....please advise....
Perhaps it is updating three records, but it may be updating the
record you think it is not with a null character.

Possible Reason: Given Mid([field1], 4), is field1 more than 4
characters in length?
Is field1 found for this row?
is field1 null?

Note that a query that updates the same record twice, once with
the correct value, and later with another value, will still show
the same "about to update 3 rows"

build a select query containing all the criteria for your update
query, and display field 1. Check and make sure.

Bob


regards
nawab


"Wayne Morgan" <co***************************@hotmail.com>
wrote in message
news:<kc*******************@newssvr31.news.prodigy .com>...
The difference between the functions with the $ and those
without is how they handle Nulls. The ones with the $ are
text only and will give you an error if you pass them a Null.

As for your second question, if it does what you want it's
ok.

--
Wayne Morgan
Microsoft Access MVP
"Nawab" <na******@hotmail.com> wrote in message
news:2b**************************@posting.google.c om...
> Hey can anyone explain to me the difference between Mid and
> Mid$ ....i notice sometimes when i a running the update
> query with Mid$ it tells me that for example 3 records will
> be updated ( which in theory is the right amount based on
> the example) however sometimes only two records are
> updated! Also in the Mid function i am not specifying the
> last argument because I need the remainder of the string
>
> example Mid([field1], 4) i am doing this becasue i want
> everything from the 4th character till the end of the
> string.....is this approach ok...
>
> please advise
> nawab


Nov 12 '05 #7

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

Similar topics

10
by: Ken VdB | last post by:
Hi everyone, Is there a reason why the Mid() function only works in one direction in VBScript? This code works in VB6 but not in VBScript? Is there a way around it? I am trying to create an...
5
by: DKode | last post by:
I have created an application that will be used for my IT depts. Tasks. I believe I have created the correct architecture but it doesn't feel correct. Could I get opionions if I am headed in the...
10
by: Tom J \(Darth\) | last post by:
Is there by chance a function in C# that can be used just like the built-in Mid(str,z,z) in VB?
8
by: A.M | last post by:
Hi, Using C#, what is the equivalent of functions Left, Right and Mid that we had in vb6? Thanks, Alan
25
by: André Almeida Maldonado | last post by:
Hy Guys, what is the methods that works like the Mid and Val VB6 Functions??? Thank's
4
by: Gordon | last post by:
Hi; I am trying to extract a substring using a combination of the mid() and Instr() i.e. aString = "Jones, Thomas R, Dr." hold = InStr(1, aString, " ," , 1) newString = Mid(aString, 1,...
1
by: Simon | last post by:
Dear reader, Some times I receive an error message by using the functions: Left(;2) Mid(;5;2)
1
by: Simon | last post by:
Dear reader, The following functions gives me some problems: Mid(,3,2) and Left() and Date(). On one pc it works perfect and on the other one an error message pop's up "Not a valid...
5
by: myra | last post by:
Hi, The problem is: I am trying to get the function call tree by using the profiling functions __cyg_profile_func_enter and __cyg_profile_func_exit. But it is printing the address of these...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.