473,322 Members | 1,562 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,322 software developers and data experts.

conditionally parse a numeric field

I've got a favor to ask -

Consider the following numeric field:

511
6805
3205
403

I need to make 2 new numeric fields from this variable, call it CS
(short for Check Station)

The first 2 numbers (even when there are only 3 digits - zeros are
missing) represent the County and the last 2 the location within the
county. County ranges from 1-88, location from say 1 to 20.

How would I create 2 new numeric fields with the following conditions:

if CS < 1000 then county=the first digit and location=the next 2

else

county=first 2 and location = next 2

Any help on this would really be appreciated.

Mike

Jul 21 '06 #1
5 1942
AP
Hello
Try

First field

iif([fieldname]<1000,left([fieldname],1),left(fieldname],2))

Second Field

Right([fieldname],2)
AP
www.megacrosstab.com

Takeadoe wrote:
I've got a favor to ask -

Consider the following numeric field:

511
6805
3205
403

I need to make 2 new numeric fields from this variable, call it CS
(short for Check Station)

The first 2 numbers (even when there are only 3 digits - zeros are
missing) represent the County and the last 2 the location within the
county. County ranges from 1-88, location from say 1 to 20.

How would I create 2 new numeric fields with the following conditions:

if CS < 1000 then county=the first digit and location=the next 2

else

county=first 2 and location = next 2

Any help on this would really be appreciated.

Mike
Jul 21 '06 #2
Like a charm! Thank you very much!
AP wrote:
Hello
Try

First field

iif([fieldname]<1000,left([fieldname],1),left(fieldname],2))

Second Field

Right([fieldname],2)
AP
www.megacrosstab.com

Takeadoe wrote:
I've got a favor to ask -

Consider the following numeric field:

511
6805
3205
403

I need to make 2 new numeric fields from this variable, call it CS
(short for Check Station)

The first 2 numbers (even when there are only 3 digits - zeros are
missing) represent the County and the last 2 the location within the
county. County ranges from 1-88, location from say 1 to 20.

How would I create 2 new numeric fields with the following conditions:

if CS < 1000 then county=the first digit and location=the next 2

else

county=first 2 and location = next 2

Any help on this would really be appreciated.

Mike
Jul 21 '06 #3
Please forgive me for being such a bother, but I barely know Access -
the code works great and I tried it in a select query. But, if I want
these 2 variables to be permanent, my thought was I needed to use an
Update Query. When I try and run it, I keep getting the message, "must
select at least one destination field." Can you please advise?

Mike
AP wrote:
Hello
Try

First field

iif([fieldname]<1000,left([fieldname],1),left(fieldname],2))

Second Field

Right([fieldname],2)
AP
www.megacrosstab.com

Takeadoe wrote:
I've got a favor to ask -

Consider the following numeric field:

511
6805
3205
403

I need to make 2 new numeric fields from this variable, call it CS
(short for Check Station)

The first 2 numbers (even when there are only 3 digits - zeros are
missing) represent the County and the last 2 the location within the
county. County ranges from 1-88, location from say 1 to 20.

How would I create 2 new numeric fields with the following conditions:

if CS < 1000 then county=the first digit and location=the next 2

else

county=first 2 and location = next 2

Any help on this would really be appreciated.

Mike
Jul 21 '06 #4
AP
Try setting the following

The table added to the query should be the table you want to update

bring the two fields down (Im assuming you added these two fields to
the table) to the design grid
for field one, in the update to box type the first expression

for field two in the 'update to' box type the second expression

Hope this helps
AP
www.megacrosstab.com

Takeadoe wrote:
Please forgive me for being such a bother, but I barely know Access -
the code works great and I tried it in a select query. But, if I want
these 2 variables to be permanent, my thought was I needed to use an
Update Query. When I try and run it, I keep getting the message, "must
select at least one destination field." Can you please advise?

Mike
AP wrote:
Hello
Try

First field

iif([fieldname]<1000,left([fieldname],1),left(fieldname],2))

Second Field

Right([fieldname],2)
AP
www.megacrosstab.com

Takeadoe wrote:
I've got a favor to ask -
>
Consider the following numeric field:
>
511
6805
3205
403
>
I need to make 2 new numeric fields from this variable, call it CS
(short for Check Station)
>
The first 2 numbers (even when there are only 3 digits - zeros are
missing) represent the County and the last 2 the location within the
county. County ranges from 1-88, location from say 1 to 20.
>
How would I create 2 new numeric fields with the following conditions:
>
if CS < 1000 then county=the first digit and location=the next 2
>
else
>
county=first 2 and location = next 2
>
Any help on this would really be appreciated.
>
Mike
Jul 21 '06 #5
Perfect! Thank you very much!
AP wrote:
Try setting the following

The table added to the query should be the table you want to update

bring the two fields down (Im assuming you added these two fields to
the table) to the design grid
for field one, in the update to box type the first expression

for field two in the 'update to' box type the second expression

Hope this helps
AP
www.megacrosstab.com

Takeadoe wrote:
Please forgive me for being such a bother, but I barely know Access -
the code works great and I tried it in a select query. But, if I want
these 2 variables to be permanent, my thought was I needed to use an
Update Query. When I try and run it, I keep getting the message, "must
select at least one destination field." Can you please advise?

Mike
AP wrote:
Hello
Try
>
First field
>
iif([fieldname]<1000,left([fieldname],1),left(fieldname],2))
>
Second Field
>
Right([fieldname],2)
>
>
AP
www.megacrosstab.com
>
Takeadoe wrote:
I've got a favor to ask -

Consider the following numeric field:

511
6805
3205
403

I need to make 2 new numeric fields from this variable, call it CS
(short for Check Station)

The first 2 numbers (even when there are only 3 digits - zeros are
missing) represent the County and the last 2 the location within the
county. County ranges from 1-88, location from say 1 to 20.

How would I create 2 new numeric fields with the following conditions:

if CS < 1000 then county=the first digit and location=the next 2

else

county=first 2 and location = next 2

Any help on this would really be appreciated.

Mike
Jul 21 '06 #6

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

Similar topics

1
by: JuniorLinn | last post by:
Hi there - I would like to share this strip of code with our SQL 2000 DBA community. The code below strips all non-numeric characters from a given string field and rebuilds the string. Very...
2
by: SQL_developer | last post by:
Hello All, I'm trying to parse for a numeric string from a column in a table. What I'm looking for is a numeric string of a fixed length of 8. The column is a comments field and can contain the...
2
by: sara | last post by:
I have a mess on my hands. I have a whole set of queries and reports (almost a whole app, really) that has "location" as a text field. Sometimes it's a number and a few times it's text (001, 002,...
1
by: S. van Beek | last post by:
Dear reader, How can I filter a numeric field with Like as criteria in a query. To filter a numeric field with <10 as criteria this will com back with the result of those records for which...
10
by: SueB | last post by:
I currently have a 'mail-merge' process in my Access db project. It generates custom filled out Award Certificates based on an SQL SELECT statement in a VBA routine invoked by clicking on a...
6
by: M.A. Oude Kotte | last post by:
Hi All, I hope this is the correct mailing list for this question. But neither postgresql.org nor google could help me out on this subject. I did find one disturbing topic on the mailing list...
29
by: gs | last post by:
let say I have to deal with various date format and I am give format string from one of the following dd/mm/yyyy mm/dd/yyyy dd/mmm/yyyy mmm/dd/yyyy dd/mm/yy mm/dd/yy dd/mmm/yy mmm/dd/yy
3
by: Naushad | last post by:
Hi All, I am trying to open the report conditionally from the dialogue box form. In the form there are three field. cboEmployees StartDate EndDate I have used these field in criteria to...
4
by: =?Utf-8?B?ZGNoMw==?= | last post by:
Is there a way to conditionally format a dateTime field to produce on result if the value is 10/31/2008 12:00 AM (user didn't enter a time) and another result if the value is 10/31/2008 5:30 PM...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.