473,657 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 27621
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******@hotma il.com> wrote in message
news:2b******** *************** ***@posting.goo gle.com...
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******@hotma il.com> wrote in message
news:2b******** *************** ***@posting.goo gle.com...
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....althou gh.....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....seco ndly....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....plea se advise....

regards
nawab


"Wayne Morgan" <co************ *************** @hotmail.com> wrote in message news:<kc******* ************@ne wssvr31.news.pr odigy.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******@hotma il.com> wrote in message
news:2b******** *************** ***@posting.goo gle.com...
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(leng th)
to return, which i am excluding...bec asue i want till end of
string....could that approach be why i am not getting every record
updated.....ple ase someone help!

"Allen Browne" <Al*********@Se eSig.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******@hotma il.com> wrote in message
news:2b******** *************** ***@posting.goo gle.com...
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******@hotma il.com> wrote in message
news:2b******** *************** ***@posting.goo gle.com...
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(leng th)
to return, which i am excluding...bec asue i want till end of
string....could that approach be why i am not getting every record
updated.....ple ase someone help!

"Allen Browne" <Al*********@Se eSig.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******@hotma il.com> wrote in message
news:2b******** *************** ***@posting.goo gle.com...
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******@hotmai l.com (Nawab) wrote in
news:2b******** *************** ***@posting.goo gle.com:
thanks for your reply....althou gh.....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....whe n 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....plea se 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******* ************@ne wssvr31.news.pr odigy.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******@hotma il.com> wrote in message
news:2b******** *************** ***@posting.goo gle.com...
> 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
5948
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 ASP page which produces a fixed width text file for import into a third party legacy application which I don't have control over. --code sample-- Dim strSomeString
5
1783
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 right direction? Here is how I have it set up. UI -> Business Rules layer -> WebService (Broadcasting from SQL Server) -> DataLayer -> SQL Helper -> SQL Server I'll start out at the UI and work my way back.
10
18660
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
38630
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
4429
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
1983
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, hold) + Mid(aString, hold + 2, InStr(hold + 1,
1
4860
by: Simon | last post by:
Dear reader, Some times I receive an error message by using the functions: Left(;2) Mid(;5;2)
1
2141
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 instruction". After a disconnecting and than reconnecting a VBA library, which was not indicated as broken, the command Mid(;3;2) works correct.
5
6058
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 fns (__cyg_profile_func_enter and __cyg_profile_func_exit) instead of the other functions. Please see the code and suggest a solution. This is running on zdcc, a gcc derivative on Windows.
0
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8516
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7353
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.