473,463 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Access 2 fields

I have records with multiple fields.
Field Extension is 5 digits
Field Exchange Needs to be filled out depending of the value of Extension

If Extension is 60000 thru 69999 then Exchange should show 85-

If Extension is 41000 thru 41999 then Exchange should show 33-

I am having a problem because of the between value that I am looking for



Thank you in Advance
Sep 5 '07 #1
11 1312
NeoPa
32,556 Expert Mod 16PB
I'm afraid this question is incomplete.
Please rephrase it so that we have all the information. We can try to help with the answers but writing a question that makes sense is your job.

MODERATOR.
Sep 6 '07 #2
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command88_Enter()
  2.  
  3. End Sub
  4.  
  5. Private Sub EXTENSION_AfterUpdate()
  6.   If Me.EXTENSION = "6" Then
  7.     Me.EXCHANGE = "85-"
  8.   Else
  9.     Me.EXCHANGE = Null
  10.   End If
  11. End Sub
Two fields Exchange and Extension
I am working with Telephone numbers. The end result should be that if I enter any number between 60000 and 69999 the result should be to put 85- in the field Exchange. Also any 42000 thru 49999 number should result in 33- in the Exchange field. The above only does this if the single digit 6 is entered. I have tried several ways to do this "6????" and "6[0-9][0-9][0-9][0-9]" are just two examples of what I have tried.
Sep 7 '07 #3
Scott Price
1,384 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. Private Sub EXTENSION_AfterUpdate()
  2. If Me.EXTENSION = "6" Then
  3. Me.EXCHANGE = "85-"
  4. Else
  5. Me.EXCHANGE = Null
  6. End If
  7. End Sub 
IF your Me.Extension field is Numeric data type... Try this:

Expand|Select|Wrap|Line Numbers
  1. If Me.Extension = 60000 to 69999 Then
  2. Me.Exchange = "85-"
  3. ElseIf Me.Extension = 40000 to 49999 Then
  4. Me.Exchange = "33-"
  5. End If
Otherwise, wrap the figures in ""'s

Regards,
Scott
Sep 7 '07 #4
missinglinq
3,532 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. Private Sub EXTENSION_AfterUpdate()
  2. If Val(Me.extension) >= 60000 And Val(Me.extension) < 70000 Then
  3.  Me.exchange = "85-"
  4. ElseIf Val(Me.extension) >= 42000 And Val(Me.extension) < 50000 Then
  5.  Me.exchange = "33-"
  6. Else: Me.exchange = ""
  7. End If
  8. End Sub
  9.  
Welcome to TheScripts!

Linq ;0)>
Sep 7 '07 #5
Expand|Select|Wrap|Line Numbers
  1. Private Sub EXTENSION_AfterUpdate()
  2. If Me.EXTENSION = "6" Then
  3. Me.EXCHANGE = "85-"
  4. Else
  5. Me.EXCHANGE = Null
  6. End If
  7. End Sub 
IF your Me.Extension field is Numeric data type... Try this:

Expand|Select|Wrap|Line Numbers
  1. If Me.Extension = 60000 to 69999 Then
  2. Me.Exchange = "85-"
  3. ElseIf Me.Extension = 40000 to 49999 Then
  4. Me.Exchange = "33-"
  5. End If
Otherwise, wrap the figures in ""'s

Regards,
Scott
Scott, thanks for your suggestion. The third post worked for my application. I could not get the correct inputs with the above solution.
Intruder
Sep 8 '07 #6
Expand|Select|Wrap|Line Numbers
  1. Private Sub EXTENSION_AfterUpdate()
  2. If Val(Me.extension) >= 60000 And Val(Me.extension) < 70000 Then
  3.  Me.exchange = "85-"
  4. ElseIf Val(Me.extension) >= 42000 And Val(Me.extension) < 50000 Then
  5.  Me.exchange = "33-"
  6. Else: Me.exchange = ""
  7. End If
  8. End Sub
  9.  
Welcome to TheScripts!

Linq ;0)>
Ling ,
Thank you this is working for me in my form.

Intruder
Sep 8 '07 #7
Scott Price
1,384 Expert 1GB
Linq's worked because he actually tested it before giving it to you :-) Glad it's working for you!

Regards,
Scott
Sep 8 '07 #8
missinglinq
3,532 Expert 2GB
Glad we could help, Intruder!

Scott's code is what some call "air code" which is to say off the top of the poster's head! It's OK to post this in response to a question, but it should be qualified as "air code" or "untested" so the the OP is warned!

You and Scott both have a great weekend!

Linq ;0)>
Sep 8 '07 #9
Scott Price
1,384 Expert 1GB
And "air code" comes off the top of "air heads" :-) LOL...

Just an FYI, the TO operator in VBA doesn't work the way I was trying to use it included in an IF---Then statement, that was why that code wouldn't work!

However, it will work in a Select Case statement in this way (go figure... M$ must have a good reason for making perfectly goofy logic where it will work in Select, but not in If---Then):
Expand|Select|Wrap|Line Numbers
  1. Select Case Me.Extension
  2.     Case 60000 To 69999
  3.    Me.Exchange = "85-"
  4.     Case 40000 To 49999
  5.    Me.Exchange = "33-"
  6.     Case Else
  7.     Me.Exchange = ""
  8. End Select
TO is also used in For---Next Loop statements to qualify the number of times to loop. I.e.
Expand|Select|Wrap|Line Numbers
  1. For I = 1 To 10
  2.     For J = 1 To 10
  3.         For K = 1 To 10
  4.             ...
  5.         Next K
  6.     Next J
  7. Next I
  8.  
It also has a few other uses, look it up in the Access VBA help file for more information.

Regards,
Scott
Sep 8 '07 #10
NeoPa
32,556 Expert Mod 16PB
And "air code" comes off the top of "air heads" :-) LOL...
Regards,
Scott
Scott,
I'm not going to go along with the Air-head thing. You're a valuable member of the team who simply put down what they could in the time they had available.
We expect questioners to check out their posts thoroughly. If we expected that of all the experts then that would limit the amount of answers that could be posted and the number of experts that could find the requisite time to post. The OPs can be expected to test out the answers as it is they that are being assisted (I'm not discouraging experts from testing their suggestions here - simply explaining that it is not seen as their responsibility).

As to M$ being responsible for your getting the If syntax all wrong...I allowed myself a little giggle at that :D
Sep 10 '07 #11
Scott Price
1,384 Expert 1GB
Scott,
I'm not going to go along with the Air-head thing. You're a valuable member of the team who simply put down what they could in the time they had available.
We expect questioners to check out their posts thoroughly. If we expected that of all the experts then that would limit the amount of answers that could be posted and the number of experts that could find the requisite time to post. The OPs can be expected to test out the answers as it is they that are being assisted (I'm not discouraging experts from testing their suggestions here - simply explaining that it is not seen as their responsibility).

As to M$ being responsible for your getting the If syntax all wrong...I allowed myself a little giggle at that :D
You're too kind, NP :-) However, I should know better than to post a snippet of code that SHOULD work without making sure that it DOES work...

Still haven't found out why M$ made me make that syntactical mistake though LOL

Regards,
Scott
Sep 10 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: CJM | last post by:
I have a query which produces different results in the Access query builder and in an ASP page (via ADO) An example of the query is: ----------------------------------------------------------...
3
by: Jon Ole Hedne | last post by:
My Access 2002-application need to work with tables from both Oracle and Access. To solve this, I want to run some querys on three views in Oracle and import the results into temporary...
6
by: Paul | last post by:
I was wondering if anyone has had an issue where using vba code to read an excel file and import the data into an access table some records are not imported from the excel file. It seems looking at...
4
by: Wayne Aprato | last post by:
I have a simple database which was originally written in Access 97. When converted to Access 2000 file format it ran flawlessly in Access 2002. I've just tried to run it in Access 2003 and I am...
1
by: Andrew Arace | last post by:
I scoured the groups for some hands on code to perform the menial task of exporting table data from an Access 2000 database to Oracle database (in this case, it was oracle 8i but i'm assuming this...
2
by: Frav | last post by:
The Reps team have been experiencing that Access 2002 unexpectedly quits while working and also lots of Corruption Failures and "Record lock can not update" messages since the upgrade from...
11
by: bbasberg | last post by:
Hello, I have been struggling with this problem for DAYS and have googled my heart out as well as reading any books I could get my hands on but I cannot find any specific references to my problem....
2
by: bbasberg | last post by:
I have been working hard to clean up my code but I am still wondering why all incoming records go to the "AddNew" part of the IF statement and never to the Edit alternative. I believe that it must be...
2
by: steph | last post by:
I have a table with 250 fields. Of course you are wondering why 250 fields... what could I possibly be storing in so many fields? I am using this table as a general import table for files that...
2
by: hakkatil | last post by:
Hi to all, I have a page that inserts excel sheet to access database. I am using asp. What I want to do is to check the inserting record if it is in the database. Basicly checking the dublicate...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
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...
0
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 ...

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.