Re: more help with programming!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



The Mid function will extract the specified # of characters from a string,
starting at the specified position. The value it returns is a String.

Mid(String, StartPosition, #ofCharacters)

Mid("200600016004",3,2) = "06"
Mid("200600016004",5,5) = "00016" (Val() then turns the string into a
number, thereby stripping the leading zeros)
Mid("200600016004",10,3) = "004" (again, Val() strips the leading zeros.

all this boils down to:
"06" & "-" & 16 & "-" & 4

Which should equal "06-16-4". You say you get "06-16-04". I don't know why
you get "04".

HTH,


"JudyT" <JudyT@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A6A6933C-2F8C-4C83-86B9-6B99A6EC7C51@xxxxxxxxxxxxxxxx
Hey John,

Okay, it returns this as text 06-16-04. As I said, not sure how it is
pulling out the fields for this end result. Can you help me?

"John W. Vinson" wrote:

On Tue, 11 Sep 2007 11:16:01 -0700, JudyT
<JudyT@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:

okay. what the engineer did is this

took a long number and converted it into a brief number but not sure
exactly
what is going on with this code. The original number is this
200600016004.
When I count from left to right, the (2) being number 1 position the (0)
being the second position, it just doesn't sort out correctly. Can you
clear
things up for me.

Brief1: (Mid([WorkLog]![COMMITMENT#],3,2)) & "-" &
Val(Mid([WorkLog]![COMMITMENT#],5,5)) & "-" &
Val(Mid([WorkLog]![COMMITMENT#],10,3))

I would expect this expression to return 06-00016-004. Is that a) not
what you
get? or b) not what you expect? What DO you expect, and what do you get?

Is the datathpe of the field Text or is it Number? It should be Text.

John W. Vinson [MVP]



.



Relevant Pages

  • Re: Enter Parametr Value
    ... "John W. Vinson" wrote: ... It's also a bad idea to split a string constant across ... Dim strTop As string ...
    (microsoft.public.access.queries)
  • Re: Replace function
    ... John W. Vinson wrote: ... case strSerialNumber1 comes last in the string - which would cause it to be ... than storing multiple values in one field!!! ...
    (microsoft.public.access.forms)
  • Re: Building a record ID
    ... John W. Vinson wrote: ... The asterisk in a LIKE query is a wildcard matching any string. ... year and month - using the wildcard to find all sequence ...
    (microsoft.public.access.gettingstarted)
  • Re: Using the DatePart function in an Access 2003 HAVING clause
    ... but I'm still getting a syntax error. ... "John W. Vinson" wrote: ... You're getting one string constant ...
    (microsoft.public.access.modulesdaovba)
  • Re: invalid parsing
    ... On Jan 24, 12:19 am, John W. Vinson ... Can anyone identify why the following is not functioning: ... If null, then field should remain null: if contains a string, ...
    (microsoft.public.access.queries)