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

Row-Numbering a Query based on Date Values

3
Hi,

My query contains three fields: Lot, Status, and Timestamp. I've sorted the query by ascending Timestamp values and would like to assign a row number ID to each row. I've tried using:

ID: DCount("Timestamp","Weighing","[Timestamp] <=" & [Timestamp])

but Access keeps returning errors and tells me that I have a syntax error. Is this because my DCount criteria involves dates?

Any help would be much appreciated!
Apr 26 '15 #1

✓ answered by Luuk

You should add '#' before, and after, the '[Timestamp]'
(see: this link)

ID: DCount("Timestamp","Weighing","[Timestamp] <=#" & [Timestamp]) & "#"

3 1668
Luuk
1,047 Expert 1GB
You should add '#' before, and after, the '[Timestamp]'
(see: this link)

ID: DCount("Timestamp","Weighing","[Timestamp] <=#" & [Timestamp]) & "#"
Apr 27 '15 #2
Luuk
1,047 Expert 1GB
But, after i tried this meself.....

I create a table 'Tabel2' with the field 'datum'

Than this query:
Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.   DCount("[datum]","[Tabel2]","[Datum]<=#" & [datum] & "#") AS DCOUNT1, Tabel2.datum, 
  3.   month(datum) AS month
  4. FROM Tabel2
  5. WHERE (((Tabel2.datum) Between #1/1/2000# And #1/12/2000#));
  6.  
gave me this result:
Expand|Select|Wrap|Line Numbers
  1. DCOUNT1    datum    month
  2. 95407    1-1-2000    1
  3. 95438    2-1-2000    1
  4. 95467    3-1-2000    1
  5. 95498    4-1-2000    1
  6. 95528    5-1-2000    1
  7. 95559    6-1-2000    1
  8. 95589    7-1-2000    1
  9. 95620    8-1-2000    1
  10. 95651    9-1-2000    1
  11. 95681    10-1-2000    1
  12. 95712    11-1-2000    1
  13. 95742    12-1-2000    1
now i'm left puzzled, why does this first column increment with 31 (or 30 after 9-1-2000) ?
Apr 27 '15 #3
Luuk
1,047 Expert 1GB
hmm, why do i find the answer just after posting my question?

The correct result is return with this query
Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. DCount("[datum]","[Tabel2]","[Datum]<=#" & FORMAT(datum,"yyyy-mm-dd") & "#") AS Expr1, 
  3. Tabel2.datum, 
  4. FORMAT(datum,"yyyy-mm-dd"),
  5. Month(datum) AS [month]
  6. FROM Tabel2
  7. WHERE (((Tabel2.datum) Between #1/1/2000# And #1/12/2000#));
  8.  
Apr 27 '15 #4

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

Similar topics

8
by: Steven Stewart | last post by:
Hi there, I have a query (QueryB) that is based on the results of another query (QueryA). When I open QueryB itself, it displays the exact records that I want. I have a report based on...
4
by: Greg Iocco | last post by:
Simple problem, but I've checked the newsgroups and couldn't find an answer. On the main swithboard is a command button to open a report. The report I built is based off a query, and the query...
2
by: Keith | last post by:
Good Afternoon, New to .Net. I am trying to pass date/time values to a MS Access query depending on what value is selected from a dropdown list box (January, February, etc). I have declared...
2
by: amith.srinivas | last post by:
Hi all, From a word macro in VBA, I am trying to create a report in access DB. The report is based on a query with a parameter. I am using Set rpt = Application.CreateReport rpt.RecordSource =...
1
by: gretchen | last post by:
I'm a fairly new access user so my question may be simple but I still need help! I have a form and a subform. I want to run an append query and populate the subform based on values in the form. I...
5
by: BerkshireGuy | last post by:
I have two functions that calculate two numbers based on based in parameters. So, the functions return a value. Is there a way to create a chart based on values from a function? The only...
9
by: bubbles | last post by:
Newbie transiting from VBA to TSQL, using SQL Server 2005 Enterprise: Need help to do this: Open Table_A WITH TableA DO UNTIL .EOF Read value from TableA.ColumnA Run SQL Statement on...
1
by: neha02 | last post by:
Hi all, this is my first post here although i've always referred this forum for help. I am trying to design a query based on 4 queries but i'm unable to get the result i want. Please help me-...
5
by: Ferasse | last post by:
Hi, I'm an occasional Ms-Access developer, so there is still a lot of stuff that I don't get... Right now, I'm working on a database that stores contractual information. One of the form that...
6
gnawoncents
by: gnawoncents | last post by:
I have a form (FRMsurveyReports) with several combo boxes (e.g. Class, ClassUnique, SurveyID, etc.) which use an SQL query based on a table (TBLSurveyResponses) for their record source. The...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.