Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort by second half of field value

Status
Not open for further replies.

Wannabeegeek

Technical User
Jul 13, 2002
9
GB
Hi,
I have created a continuous form where one of the fields contains a user entered vaule in the format '0103','0203','0303','0104','0204','0304',etc. The first two digits are a serial number and the last two are the year in which that serial number was allocated. When the form displays it is sorted by this value.

I would like it to sort by the year segment first and then by the serial number segment as opposed to the current 0103,0104,0203,0204,etc.

I'm sure that there is a simple solution to this but as yet it escapes me. Any suggestions would be appreciated.
 
Wanna,
in a blank entry on the query grid "field" ;
Right([yourfield],2) & Left([yourfield],2)
then use it to sort.
jim
 
How are ya Wannabeegeek . . . . .

If the [blue]RecordSource[/blue] of the form is not already based on a [blue]Query[/blue], make it so.

In the query your going to add two custom fields for your new sort. In trhe 1st empty field on the [blue]field row[/blue], copy/paste the fillowing:
Code:
[blue]srtYr: Year("1/1/" & Right([qCode],2))[/blue]
Set sorting Ascending/Decending.

In the next empty field copy/paste the following:
Code:
[blue]srtSer: Val(Left([qCode],2))[/blue]
Set sorting Ascending/Decending.

If you'd rather use [blue]SQL[/blue] as the [blue]RecordSource[/blue] for the form, you can copy it in SQL view, then paste it in the RecordSource of the form.

Calvin.gif
See Ya! . . . . . .
 
How are ya xaf294 . . . .

And if he has years that [blue]crossover 2000[/blue] or 0900?

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top