By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,959 Members | 1,139 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,959 IT Pros & Developers. It's quick & easy.

Enquiry code: showing records within a period

P: 1
I having a table something like this:

startdate | stime | endate | etime | tool
3/3/07 | 8:47 | 3/4/07 | 00:30 | A
3/4/07 | 3:57 | 3/4/07 | 4:30 | B
3/4/07 | 8:21 | 3/4/07 | 9:20 | C

Currently I have a form which use to open daily1 form.
I have one textbox[date] for enter date and a button to view.
Is it possible if I want enter 3/4/07 on the text box
it will give me the records from 3/3/07 7:00 till 3/4/07 7:00
(thus, only show tool A and tool B)

my currently event procedure for the button is below:

Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2. Dim strWhere As String
  3.  
  4. If Not IsNull(date) Then
  5. strWhere = strWhere & " AND startdate = " & "#" & _
  6. date & "#"
  7.  
  8. If Not IsNull(strWhere) Then
  9. strSQL = Mid$(strWhere, 6)
  10. End If
  11.  
  12. strForm = "daily1"
  13. DoCmd.openform strForm, , , strSQL
Anything can be modify on the code in order to search the records base
on the time interval?
Thanks =)
Mar 20 '07 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Dim strWhere As String
  2. Dim strForm As String
  3.  
  4. If Not IsNull(date) Then
  5. strWhere ="startdate=#" Me!date - 1 & "#" & _
  6.    " AND stime >= 7:00) OR (startdate=#" Me!date & "#" & _
  7.    " AND stime <= 7:00) "
  8.  
  9. strForm = "daily1"
  10. DoCmd.openform strForm, , ,  strWhere
  11.  
Mary
Mar 22 '07 #2

Post your reply

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