An expression to create a sequential number field based on date (1 Viewer)

tmort

Registered User.
Local time
Today, 09:10
Joined
Oct 11, 2002
Messages
92
I would like to creates some queries that subtract the value from one day to the next. Not every day will have a value so it looks way to do this is with a sequential number field based on the date. I thought the way to do it was with the autonumber fields but not all of the values will necessarily be entered sequentially.

I'm thinking of some sort of query to sort by date and then with an expression to add sequencial numbers to another field.

Any ideas?

Thanks in advance
 

llkhoutx

Registered User.
Local time
Today, 03:10
Joined
Feb 26, 2001
Messages
4,018
Date is a number. Hours, minutes and seconds aare the fractional part. Therefore, is the fractional part of the date s being used, convert the date to long integer. Start your autonumber index with a long integer (date) value.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 03:10
Joined
Feb 28, 2001
Messages
27,191
More specifically,

loSeqNo = CLng( dtDateTime )

where

Dim dtDateTime As Date

In case you were wondering, the number you get is the integer number of days since the date reference = 1 - Jan - 1900 @ 00:00
or something close to that.
 

tmort

Registered User.
Local time
Today, 09:10
Joined
Oct 11, 2002
Messages
92
Sequential numbers in query

The values I have don't include time so that won't work, plus I don't know VB.

I found a function at www.lebans.com that creates sequential numbers in queries and forms.

I'm attaching a db with the function.

I'm also attaching a simple db in which I try to use it to no avail.

I copied the code from the example db and pasted it into the test db and also saved the code as a bas file and then imported it into the test db and called it in a query. I get an error both ways.

Can someone see what I am doing wrong. I know it works because the example works.

Thanks in advance
 

Attachments

  • rownumberver2.zip
    57.5 KB · Views: 222

tmort

Registered User.
Local time
Today, 09:10
Joined
Oct 11, 2002
Messages
92
Sequential numbers

Here is the other file that isn't working that I reffered to
 

Attachments

  • row number test.zip
    40.6 KB · Views: 223

Users who are viewing this thread

Top Bottom