473,386 Members | 1,820 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,386 software developers and data experts.

Search Filter Question

Hi,
I have an Access 2003 database I am running with vb 6. I have one report that I want to filter on the Start_Date and Stop_Date in a scheduling database. I would like to enter a stop and stop date, then have it look for anything that the start date or stop date range falls into the start and stop date I specify. I know how to do it if searching only the start_date or only the stop_date,but can't figure out how to make it look at both.

I know that if I put

Expand|Select|Wrap|Line Numbers
  1. Between [Start Date] and [Stop Date]
in the criteria field on the Start_Date in the querry it will prompt me for a Start Date and a Stop Date and will search the Start_Date field. But I want it to search the Stop_Date field in the database at the same time as well and return anything matching the dates I specify.
Dec 6 '06 #1
5 2113
Also, can you rotate a label on an Access report?
Dec 6 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. WHERE Start_Date >= [Start Date]
  2. AND Stop_Date <= [Stop Date]
  3.  
Try this ...

Mary
Dec 6 '06 #3
Thanks Mary. Below is what I wound up with that works. Except now when the access report opens, even though I pass the arguement "vbMaximized", the access report still doesn't open maximized.

Expand|Select|Wrap|Line Numbers
  1. Dim LDT1 As Date
  2. Dim LTD2 As Date
  3.  
  4. LDT1 = frmGroundOperationsSelectReport.DTPicker1.Value
  5. LDT2 = frmGroundOperationsSelectReport.DTPicker2.Value
  6.  
  7. If CStr(LDT1) = "" Or CStr(LDT2) = "" Then
  8.     Exit Sub
  9. End If
  10.  
  11. Set appaccess = CreateObject("Access.Application")
  12.  
  13. dbstr = "C:\Scheduling\AAGTC_Scheduling.mdb"
  14.  
  15. appaccess.OpenCurrentDatabase dbstr
  16.  
  17. appaccess.DoCmd.OpenReport "DailyGroundScheduleReport", acViewPreview, vbMaximized, wherecondition:="[Date_In] Between" & _
  18.  " " & "#" & LDT1 & "#" & " " & "And" & " " & "#" & LDT2 & "#" & " " & "Or" & _
  19.  " " & "[Date_Out] Between" & " " & "#" & LDT1 & "#" & " " & "And" & " " & "#" & LDT2 & "#"
  20.  
  21. appaccess.Visible = True
Dec 6 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
This parameter is for passing a filter as follows:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "ReportName", acViewPreview, Filter, LinkCriteria
  2.  
You need to put the following command in the on open event of the report instead.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.Maximize
  2.  
Mary
Dec 6 '06 #5
NeoPa
32,556 Expert Mod 16PB
Try this less involved version :
Expand|Select|Wrap|Line Numbers
  1. Dim LDT1 As Date
  2. Dim LTD2 As Date
  3. Dim strWhere As String
  4. Dim strDate1 As String
  5. Dim strDate2 As String
  6.  
  7. LDT1 = frmGroundOperationsSelectReport.DTPicker1.Value
  8. LDT2 = frmGroundOperationsSelectReport.DTPicker2.Value
  9.  
  10. If CStr(LDT1) = "" Or CStr(LDT2) = "" Then Exit Sub
  11.  
  12. Set appaccess = CreateObject("Access.Application")
  13.  
  14. dbstr = "C:\Scheduling\AAGTC_Scheduling.mdb"
  15.  
  16. appaccess.OpenCurrentDatabase dbstr
  17.  
  18. strDate1 = Format(LDT1, "\#m/d/yyyy\#")
  19. strDate2 = Format(LDT2, "\#m/d/yyyy\#")
  20. strWhere = "(([Date_In] <= " & strDate2 & ") And (" & [Date_Out] >= " & strDate1 & "))"
  21.  
  22. appaccess.DoCmd.OpenReport "DailyGroundScheduleReport", acViewPreview, vbMaximized, strWhere
  23.  
  24. appaccess.Visible = True
In VBA (I'm assuming in VB too) you can't use named parameters unless all are named.
ALL date literals in SQL MUST be in d/m/y format (which isn't the default in all locations).
The logic is that one StartDate must be less than or equal to the other EndDate AS WELL AS the EndDate (of the first StartDate) must be greater than or equal to the other StartDate.
Dec 7 '06 #6

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

Similar topics

2
by: Rafael Nenninger | last post by:
This question has to do with MS file search but it is happening only with ..asp pages, so I though someone programming with .asp pages has experienced the same situation. I'm trying to find .asp...
1
by: N. Graves | last post by:
Hi, I want to have a Search Dialog box that has several text box and fields to build a search and display the results in a form. I can do everything that I need to if I us a report but I would...
9
by: Christopher Koh | last post by:
I will make a form which will search the database (just like google interface) that will look/match for the exact name in the records of a given fieldname. Any suggestions on how to make the code?
8
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled...
23
blyxx86
by: blyxx86 | last post by:
I am trying to filter multiple entries with only one search box. That way the user can type whatever they want and find all the values that contain what they enter. Private Sub...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
3
by: Elainie | last post by:
I would like to search a form with many fields on it, with out using the search facility through access. Througth a drop down list if possible.... How would I go about this? How could I also...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
2
by: woodey2002 | last post by:
Hi Guys and thanks for your time. I have a search form for my database that allows users to select multiple criteria from multi select list boxes. I successfully integrated a multi select...
6
by: woodey2002 | last post by:
Hi Everyone. Thanks for your time. I am trying to create a search form that will allow users to select criteria from multiple multi select boxes. So far i have managed to achieve a search option...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.