Sort Alphanumeric Field - Code Problem
Dec 1, 2006
hi
i found this code here and it works IF the number comes first and is preceded by a letter
123AA
but it does not work if the letters come first
AA123
here's the code
Public Function GetString(WholeString As String) As String
Dim i As Integer
Dim Temp As String
Temp = CStr(WholeString)
For i = 1 To Len(WholeString)
If InStr(1, "0123456789.", Mid(Temp, i, 1)) = 0 Then
GetString = Mid(Temp, i)
Exit Function
End If
Next i
GetString = Temp
End Function
Public Function GetNumber(WholeString As String) As Double
Dim Temp As String
Dim i As Integer
Temp = CStr(WholeString)
For i = 1 To Len(Temp)
If InStr(1, "0123456789.", Mid(Temp, i, 1)) = 0 Then
GetNumber = Mid(Temp, 1, i - 1)
Exit Function
End If
Next i
GetNumber = Temp
End Function
the probelm is with this line but i'm not sure what it is
GetNumber = Mid(Temp, 1, i - 1)
(i also get runtime error 13) but my data is in the same format as the example i downloaded.
any ideas anyone?
thanks in advance and thanks to the person who created the code
View Replies
ADVERTISEMENT
Nov 1, 2006
Access does not have an option to sort alphanumeric strings properly with the result that sorting a column with the following (sort of) data is almost impossible.
Flat A1
Flat A10
Room A13
Room A2
Room A21
B5
Flat 5b
10k1
10 k3
10 k12
10 k20
10 k2
etc
I need to be able to get addresses sorted correctly and they always have a mixture of alphabetic and numeric characters.
The steps I have followed to try and achieve this are as follows:
Create a matchfield containing the data for sorting (typically the street number followed by the flat number/name)
Split the matchfield into separate fields where there are spaces. "Room A13" becomes "Room", "A13"
Then split the fields/columns by separating the alphabetic and numeric portions - i.e. "Room A13" becomes "Room", "A", "13". This I have not been able to achieve successfully.
(Thinking about it the first step of separating by spaces is probably not necessary. All that is needed is to separate the numeric and alphabetic data)).
Once you have separated the data into alaphbetic and numeric content a sort is straightforward.
Why can't Access cope with what I would regard as a fairly basic requirement (i.e. to be able to sort alphanumeric strings correctly).
Does anyone have a suggestion how I can solve this problem until Access is improved?
View 11 Replies
View Related
Mar 13, 2013
I want to know if there's a way to sort alphanumeric fields where the number of digits aren't always the same.
Example: I have the following: 2a, 10a, 3a.
Currently, it sorts: 10a, 2a, 3a.
Is there a way to get it to sort 2a, 3a, 10a without adding a 0 before 2a and 3a?
View 5 Replies
View Related
Sep 30, 2005
I have a text field in a table that contains an alphanumeric code. i.e.
DEL998
DEL999
DEL1000
DEL1001
SUN998
SUN999
SUN1000
SUN1001
SUN1002
etc.
I want to run a query to find the highest number for a particular alpha code. In the example for DEL I would want the query to return DEL1001.
I have created a select query that asks for the alpha code, selects all codes starting with that code, sorts them in decending order and only displays the first record.
The problem is that because the field is a text field the numeric is not sorted like a number. So in the DEL case the query returns DEL999.
Any ideas on how I can get a result of DEL1001??
Thanks for your help
View 1 Replies
View Related
Feb 5, 2015
I have a database I have worked on for the sister company of the place I am employed.I have a field I am trying to make alphanumeric that has been numeric. (PO Number on the main form). I had make it alphanumeric a couple of months ago, but it disabled the Edit Customer Information button on the bottom right of the form to where I cant enter shipping addresses and things like that. It should be able to enter multiple shipping addresses.
I need making the PO Number field button alphanumeric and making sure it doesnt mess-up the Edit Customer Information button. I have attached both versions of my database. The GM at the sister company would also like me to create a Spin button where you can take an old record and keep all of the previous information on it, except it gives it a new Work Order# and you can change the date to something newer.
View 4 Replies
View Related
Mar 31, 2008
I have searched this forum but didn't find the answer, I hope I'm not the only one with this problem.
I have two text fields in a table that are updated through an excel file import. In the excel file, both fields contain data that is mostly numeric, but there are always about a quarter that contain letters as well. When I go to import the excel file, it sets to null any value in the fields that contains letters. If I sort the excel file in descending order for the field, it will import, but I have two fields that do this, so this brings more problems. Does anyone know why you can't just import anything in any order into a text field?
View 14 Replies
View Related
Mar 5, 2015
I've got most of what he wants sorted but this last task I am completely flummoxed. All of his projects are allocated an ID (named Project Reference), starting from P010010 and increasing by 1 each time. I've made a form that allows a new project to be recorded by entering all the details and hitting the 'record' button, but he wants the Project Reference field to be automatically filled in each time (understandably), increasing by 1 from the last record.
So if the last record was P010311, then when the form opens the Project Reference should automatically be P010312.
I've looked into this and found many guides talking about DMax and DIM and strCriteria and whatnot, but no matter how many of them I follow and try to adapt to my own database I can't get it to work at all.
The table the ID comes from is called General, and the field is Project Reference. The ID should automatically be filled into a text box called txtRef whenever the form opens and a button to add a new record is pressed, being 1 higher than the previous ID.
View 1 Replies
View Related
Dec 6, 2013
What would I need to enter into the validation rule to change the field to alphanumeric only?
View 3 Replies
View Related
Nov 13, 2014
I have an existing form where users type in information and it generates a couple of reports. In one of the fields, Customer PO Number, the user enters a number from a customer. Up until yesterday all of the customers we have been dealing with have used numbers only for their PO numbers. However, we have a new customer that requires alphanumeric PO's. Is there a simple way to change this field from a number to alphanumeric without having to redo each form, report and/or query. I am using MS Access 2010.
View 9 Replies
View Related
Dec 27, 2013
I have a table having the following fields:
StaffNo TextField PrimaryKey
Name
....
...
The data in StaffNo will be alpha numeric, like AKA-111, AKA-112, LMN-100, LMN-102
Here AKA and LMN describes the Sites where employee is working.
On Add New Employee, When user enter AKA- in StaffNo, on exit the next number on that site should be generated. i.e AKA-113.
View 8 Replies
View Related
Mar 1, 2005
I am trying to set the default sort code to something other than the primary key. Example- Book Code is Primary Key but I want the table to be sorted by Title. I have went into properties and used the Order By property and typed 'Book.Title' however when I view the datasheet, Book Code is still the 1st column??? Is it still being sorted by Title??
Any help would be greatly appreciated
View 2 Replies
View Related
Apr 3, 2015
I would like to enter a couple of alphanumeric groups into a field on an input form. After I enter an alphanumeric group, I hit the enter and the data will add into the field and refresh to empty box ready for next entry. If I continue to enter another group and hit enter, the next group will be added to original field with a comma and a space in between. build the VBA in after update event to accomplish the task.
View 14 Replies
View Related
Aug 8, 2013
When I "Add Existing Fields" I'd like the list to be sorted alphabetically...how to do this?
View 4 Replies
View Related
Aug 17, 2013
I created a table by importing data from an Excel spreadsheet. Now I have discovered that I am unable to filter the data, i.e. do an ascending and.or descending sort, in the first field of the table, which is a long text field. It is the only field that has text, all others are yes/no fields. Is there any way to fix this?
View 5 Replies
View Related
Jul 21, 2006
I have a query that draws from two tables, and the field in question looks like this:
X: [TableData]![FieldA]*[TableNumbers]![A]+[TableData]![FieldB]*[TableNumbers]![B]
It all works fine and dandy, but once I set it to sort by this field and run the query, it gives me the parameter prompt, asking me to enter the Parameter Value of FieldA and then for FieldB.
Is there a work-around for this within the query?
The only other solution I have in mind is making another table from this query, and then creating another query just for sorting said table, but that seems inefficient at best.
View 2 Replies
View Related
Mar 16, 2008
I have an expression in a query
Expire: IIf([payterm]="X","",DateAdd([payterm],1,[orderdate]))
However when I sort it it does not sort in correct manner
it's goes like
1/11/2007
1/15/2008
10/10/2006
10/16/2007
10/31/2007
10/5/2006
I have the field properties set to Short Date.
What do I need to do for this to sort right?
View 2 Replies
View Related
Sep 16, 2005
I have a form that has a bunch of project information and scrolling buttons at the bottom to browse by next/last.
Right now the form is sorted by the ID associated with the project, which kinda sucks because they were and are not put in alphabetically.
I discovered if you right click on a field and click "Sort Ascending" or the opposite it works fine but when I open the database it is right back to normal ID sort
I have checked the Data and Other tabs but can't find anything with regards to this as well as I have tried sorting the actual table by name and that changed nothing.
Any help would be greatly appreciated.
View 1 Replies
View Related
Sep 14, 2004
I have a lookup field for my table that pulls its data from Pay period table
When I click the drop down in my table, the dates aren't in any order. I think this is because lookup fields are considered text fields.
Is there a way to sort my drop down box on the table?
KellyJo
View 2 Replies
View Related
Sep 19, 2004
I am trying to remove a "sort and grouping" field from my report. I delete the field from the menu by using the "backspace" key on my key board. I am getting any error, invalid sort field. When I put something into the field, the error goes away. How do I delete a sorting field I do not want??
thanks for your help
newbie and learning
View 1 Replies
View Related
Aug 12, 2014
I have a query that lists items in locations in our warehouse. Each location is broken down by Aisle-Bay-Level-Position, for example 50-101-01B; or 51-106-02 with all the even Bays on one side and Odd bays on the other side of the aisle. I have the query set up so it separates odd and even so I can go all the way down one side of the aisle then I have to walk back to the beginning of the aisle to check the other side.
What I am trying to do is change the sort based on another field that I have called SORT with a value of AZ or ZA depending on if I need that section to be sorted ASC or DESC. So for example all even bays in aisle 51 need to be sorted DESC while all ODD bays would be ASC. The way our warehouse is laid out it is not always the odd or even side that needs to be sorted DESC, that's why I made the SORT field. The formula I used for the SORT field is as follows:
SORT: IIf(([Aisle]='50' And [OE]='ODD') Or ([Aisle]='51' And [OE]='ODD') Or ([Aisle]='53' And [OE]='ODD') Or ([Aisle]='52' And [OE]='EVEN'),'AZ','ZA')
Is there a way to make it sort the BAY in ASC or DESC based on the value in SORT?
As an example here is how I want the order to be:
50-101-01A
50-101-01B
50-103-02A
50-103-02B
51-101-01
[Code] .....
View 1 Replies
View Related
Aug 1, 2012
I have a form where data can be added and it has different tabs. The 3rd tab has idVersion field and Comment field where users can add the version and comment, if needed. When they need to add another version, the blank fields will be added as next row, so on and so forth. The problem is users are adding a lot of versions but not sorted. So for example:
Row 1 of the form: idVersion field is "1" and comment has "Test 1".
Row 2 of the form: idVersion field is "8" and comment has "Test 8".
Row 3 of the form: idVersion field is "2" and comment has "Test 2".
Row 2 of the form: idVersion field is "5" and comment has "Test 5".
So how can I fix it where after they saved the version and comment, when they close the database and re-open it again, the data will show up as:
Row 1 of the form: idVersion field is "1" and comment has "Test 1".
Row 2 of the form: idVersion field is "2" and comment has "Test 2".
Row 3 of the form: idVersion field is "5" and comment has "Test 5".
Row 2 of the form: idVersion field is "8" and comment has "Test 8".
So even if they add a new version and comment (example version "3"), it will be automatically sorted when the database is reopen.
View 6 Replies
View Related
Jan 11, 2007
Below is the sql code I have for a CrossTab Query. Total as GrandTotal
shows GrandTotal of all weekly columns. Is there anyway I can get the
Query Display to sort on the GrandTotal Column?
PARAMETERS [Forms]![Queries_ReportsFRM]![StartDateTxt] DateTime, [Forms]![Queries_ReportsFRM]![EndDateTxt] DateTime, [Forms]![Queries_ReportsFRM].[FaultCategory] Text ( 255 );
TRANSFORM Sum([Trends-1-3TON-WEEK].Totals) AS SumOfTotals1
SELECT [Trends-1-3TON-WEEK].SystemGroup, [Trends-1-3TON-WEEK].FaultCategory, Sum([Trends-1-3TON-WEEK].Totals) AS GrandTotal
FROM [Trends-1-3TON-WEEK]
GROUP BY [Trends-1-3TON-WEEK].SystemGroup, [Trends-1-3TON-WEEK].FaultCategory
ORDER BY Sum([Trends-1-3TON-WEEK].Totals)
PIVOT [Trends-1-3TON-WEEK].YearMonthWeek;
View 1 Replies
View Related
Mar 1, 2007
I want a field to be a serial number made up of a letter of the alphabet followed by 3 digits. I want the digits to increase by 1 in each of the following record. For Example the serial number in the first record would be A001, then followed by A002, A003, ....., A142, A143, A144 & so on. I am fairly new at Access but I have experimented with AutoNumber, it won't work if the Field is not a pure mumber, can't get autonumbering to happen if I treat the field as text. I don't know where to go from here.
Any help is much appreciated.
Rob Shakesbeer
View 3 Replies
View Related
Dec 14, 2007
I know that I could have done a better effort searching the forums and other places but you'd think that the answer to this would be easy: how do you set a Validation Rule for a field where a person can only enter an alphanumeric value?
I'm setting up an invoice tracking database and one of the recurring problems end users have is the inconsistent entering of an invoice number with symbols. We want to eliminate this and have them enter ONLY alphanumeric values. In other systems I've used, this has been easy to setup. But not in Access. Can someone advise? I've been trying to deal with this for two days.
Thanks...
View 9 Replies
View Related
Mar 8, 2013
My table has 3 fields, Employee Number (text), Job Description (text) and Current (yes/no). The table keeps track of the Job Descriptions that an Employee has had along with his current Job Description (actually Title is more appropriate a word but client requested Description) So the table has records such as:
0001 - Floor Sweeping - no
0001 - Ceiling Cleaning - yes
0001 - Dumpster Turning - no
The yes signifies that that is the current Job Description for employee #0001 and the others with no are previous Job Descriptions that the employee #0001 has held.
Now - I created a form to add these records to the table and on that form I want a list box to show the records in the table for this employee but I want to sort it such that the current Job Description is listed first and the rest show up in alphabetical order following. I have the query to list all of the Description, but how can I get the current one to always appear on the top of the list?
View 14 Replies
View Related
Apr 22, 2013
I have a query with a float/delta column which is the expression:
Code:
Float: [Date1] - [Date2]
When I try to change the order by in the column filter drop-down i get a data type mismatch in criteria expression error.
View 1 Replies
View Related