473,395 Members | 2,443 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,395 software developers and data experts.

Numbers in Access

I have a table that holds Employee Information which includes the following fields: EmployeeID(AutoNumber), EmployeeNo(Long Integer), EmployeePin(Long Integer), and EmployeeName(Text). I assign employee numbers in increments of 10. (i.e. 10, 20, 30, 40...)

I use the following code in a form's on load event to to assign a unique employee number to the EmployeeNo Field.

Expand|Select|Wrap|Line Numbers
  1.  
  2. strSQL = "SELECT TOP 1 EmployeeNo FROM tblEmployees ORDER BY tblEmployees.EmployeeNo DESC;"
  3.  
  4. Set rs = CurrentDb.OpenRecordset(strSQL)
  5.  
  6. Dim NewEmpNo As Long
  7.  
  8. NewEmpNo = rs.Fields("EmployeeNo")
  9.  
  10. Me.txtEmpNo = NewEmpNo + 10
  11.  
  12.  
The problem is that once I have an employee number of 90 my code never produces a number higher than 100. I know what's happening and how Access sees numbers in the following order 10, 100, 20, 30, 40....80, 90.

My question how can i get my access query or SQL statement to see 100 as the highest number instead of 90.
Mar 15 '12 #1

✓ answered by BikeToWork

You say your Employee Number field is a long but the sorting you describe is for a text field. Numbers are sorted numerically in Access. Check again on the datatype of the Employee Number field.

Try:
Expand|Select|Wrap|Line Numbers
  1. Me.txtEmpNo = Clng(NewEmpNo) + 10

4 1634
BikeToWork
124 100+
You say your Employee Number field is a long but the sorting you describe is for a text field. Numbers are sorted numerically in Access. Check again on the datatype of the Employee Number field.

Try:
Expand|Select|Wrap|Line Numbers
  1. Me.txtEmpNo = Clng(NewEmpNo) + 10
Mar 15 '12 #2
Thanks for the quick reply!

You are correct. EmployeeNo is stored as a text field. However the example you provided did not change the outcome. I feel like a number field should be stored as such, so I will change that. Are you saying that a number stored as Long will sequence the way I need?
Mar 15 '12 #3
BikeToWork
124 100+
Change the datatype of your EmployeeNo field to long and the field will sort numerically. Previously, I did not notice in your code that NewEmpNo is already declared as a long, so the Clng function will not do anything there.
Mar 15 '12 #4
Actually, I made the change to Long and it WORKS! Thanks!!
Mar 15 '12 #5

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

Similar topics

1
by: Emilio | last post by:
(MS Access 2002) Hello, I'm working with some big Census (PUMS) files, and I run into a peculiar problem once the data field exceeds five integers. I'll explain every step, since I am doing it in...
0
by: Sabine Oebbecke | last post by:
Hi Experts! I have several forms and reports where controls get their values with 'Forms!MainForm!Control' or 'Forms!MainForm!Subform!Control' resp 'Forms!MainForm!Subform.Form!Control' which...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
0
by: russ | last post by:
Hi I have found what looks like a bug in Access or XP Pro. When I have the following in a table in Access 1996 0.08715292 1996 12.98775 1996 1.987653 1996 0.09476294
7
by: Shannan Casteel via AccessMonster.com | last post by:
I have a form for entering part numbers along with the associated quantity for each part. There are 25 Part fields and 25 associated Quantity fields. If I go to record 1 and enter part number 1234...
37
by: MLH | last post by:
For example: Nz(,0) returns "300" if the value in field is 300 (currency data type) and "0" if the value is zero or null. I get strings in the query output - they are all left aligned and I...
24
by: cassetti | last post by:
Here's the issue: I have roughly 20 MS excel spreadsheets, each row contains a record. These records were hand entered by people in call centers. The problem is, there can and are duplicate...
24
by: Kosmos | last post by:
Hey guys I'm a newbie and in fact I'm not even a programmer but decided to take up the task of learning access and creating a database. And I've gotten pretty far in terms of importing from excel and...
3
by: emalcolm_FLA | last post by:
Hello and Thanks in advance for any help. I have been tasked with rewriting a christmas assistance database using Access 2003. The old system used pre-assigned case numbers to identify...
7
by: DefaultWorkgroup | last post by:
Good Morning Ladies and Gentleman. My question is in MS Access 2000 (I know is old, is all I have) I’m basically a Newbie in this posting of new threads and in the MS Access as well. I...
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: 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...
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
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
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...
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...

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.