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

Need Help with Multiple Search in a Form...

Hello,

I have a form that I'm currently using as a search screen, and I'm having trouble passing a range to one field in a query.

I want to call a date range, let's say between date1 and date2 and pass that value to my [Date] field in the query, however I cannot figure out how to do this... I already have two date boxes in the form.

Below is an example of another value I'm sending to the query through VB. It is then queried through a button in the form...

Expand|Select|Wrap|Line Numbers
  1. ' Check for LIKE Client Name
  2.     If Me.Text2 > "" Then
  3.         varWhere = varWhere & "[Client Name] LIKE """ & Me.Text2 & "*"" AND "
  4.     End If
Jun 15 '11 #1
2 1540
beacon
579 512MB
Since it sounds like you've got two date fields in your query, and you've got two textboxes on your form to accept the dates, you've actually got the majority of the work done. Now it's just a matter of telling the query that it needs to look for the dates on the textboxes on the form.

I'm going to make a couple of assumptions about your query/form setup, so you'll obviously have to swap the names out with the actual names you are using.

On your query, let's say your date field in the query is called MyDate, and on your form, which we'll call YourForm for lack of a better description, you're two text boxes are called txtStartDate and txtEndDate. I don't know if [Date] in your post was the name of an actual field, but if it is you need to rename it. Access uses Date as a keyword, so using it for anything else will cause a bunch of problems down the road, if they haven't already.

Ok, go to your query...in the criteria for MyDate, enter the following code:
Expand|Select|Wrap|Line Numbers
  1. Between [Forms]![YourForm]![txtStartDate] And [Forms]![YourForm]![txtEndDate]
  2.  
The preceding code tells your query that when it runs it needs to go to YourForm and grab the values in txtStartDate and txtEndDate.

Ok, now let's go to your form. It sounds like you've already got a button to call/open the query, so that should be good to go. The only other thing I would suggest is that you may want to add similar conditional testing to the date controls on your form to ensure that the user enters a date prior to running the query so it doesn't return unexpected values.

Hope this helps,
beacon
Jun 15 '11 #2
Thank you for the response. This would work, however it's a bit more complex. I have other ranges than I would like to call within that query and I can't because then I get a "Complex error". Is there a way to do this through the code?
Jun 15 '11 #3

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

Similar topics

4
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a form with multiple pages on it. There is one text field on the third page of the form that I need the user to complete before leaving the form or moving...
3
by: screenwriter776 | last post by:
Hi, folks - Perhaps you could help me with a search form I am building. I have a table with a field in it. I want to return dates inside two parameters the user enters into a search form:...
1
by: Holger (David) Wagner | last post by:
Hi there, we have an application which is built with several ASCX controls some of which contain form elements (e.g. Textboxes, Buttons etc.) For example: in the top section (one...
4
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure...
4
by: Ron S | last post by:
Hello everyone, I am trying to finish an application and I have been strugling with the last two forms. What I am trying to do is create a two search forms with unbound text boxes and a...
22
by: mforema | last post by:
Hi everybody, I need help with a search form. I'm trying to search a table based on "Keywords" and "MajorCategories"; both criteria have their own fields in the table. The form has a "keyword"...
8
by: salzan | last post by:
I have this code: strAny = " = " & rsTemp!YearId rsPerm.Find strAny and it works. However, when I do the following it doesn't strAny = " = " & rsTemp!YearId & " AND " & _ "...
2
by: MNNovice | last post by:
I am working on a database on my CD collection using Access 2003. Some of the table structures are given below. Table 1 tblMusicCategory Field 1: MusicCategoryID - Auto Number (PK) Field 2:...
1
by: josil | last post by:
Hi I'm a newbie in this and need help. I mange to make a one field search form. But now I want to go further. How can I make a multiple field form? <h2>Search</h2>
11
by: TheKimmy | last post by:
Okay, so I'm working on a database application with a search form that covers a ton of fields. And everything worked fine, until I tried to set it to pull records that have a value between two...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.