473,626 Members | 3,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search Form

f430
43 New Member
i have been trying to write a search code for a similar database, and i followed all the steps that were provided above, and my code was close to what lightning had but i have added date range in my search to search in between 2 dates, and i put this code in:

Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Me.date1) Then
  2.         strWhere = strWhere & "([Date] >= " & Format(Me.date1, conJetDate) & ") AND "
  3.     End If
  4.        If Not IsNull(Me.date2) Then
  5.         strWhere = strWhere & "([Date] < " & Format(Me.date2 + 1, conJetDate) & ") AND "
  6.     End If
do you think that code is correct??


i am also having problems with the last step, where u do "DoCmd.Open Form "masterform ", , , strFilter"
i did that but i keep getting an error message, and when i go to debug this line is always highlighted.

i have a table called master form which has all my information, i made a form that is a duplicate to my master table in order for the last step to work, but i am not sure what is wrong.

Mary, i really hope you can help me with this, since you seem to be the only active member!!

i would appreciate any help on this.
Thanks

** Edit **
This post was a hijack of Search Form: multiple controls (Access 2003). I will split it across to its own thread. Please remember in future to create a new thread for your questions.
Aug 5 '10 #1
9 1842
Michael Adams
55 New Member
f430

I am using a calendar control for searching between two separte dates to find information. Is this what you are looking for?
I, for instance, am using a combo box with the event of mousedown to bring up the calendar for both the from date and the to date. Is this something you would like to see?
Aug 5 '10 #2
f430
43 New Member
i am using a text box to enter the date as in mm/dd/yy.
but i dont think my code is working out.
so i think a calendar view would work a lot better.
i would appreciate some help with this coding for this calendar view

thanks
Aug 5 '10 #3
NeoPa
32,567 Recognized Expert Moderator MVP
Hopefully, splitting this question into its own thread will give you a greater chance of getting any responses.

Good luck and welcome to Bytes!
Aug 6 '10 #4
Michael Adams
55 New Member
Here is what I found and that is working for me.
This is the code for the "From" combo box, the name I used was fromdatecmb and the calendar is named ocxcalendar

Expand|Select|Wrap|Line Numbers
  1. Private Sub fromdatecmb_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.  
  3.     Set Originatorcmb = fromdatecmb
  4.  
  5.     ocxcalendar.Visible = True
  6.     ocxcalendar.SetFocus
  7.     If Not IsNull(Originatorcmb) Then
  8.         ocxcalendar.Value = Originatorcmb.Value
  9.     Else
  10.         ocxcalendar.Value = Date
  11.     End If
  12. End Sub
Now here is the code I use for the todatecmb box

Expand|Select|Wrap|Line Numbers
  1. Private Sub todatecmb_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.     Set Originatorcmb = todatecmb
  3.  
  4.     ocxcalendar.Visible = True
  5.     ocxcalendar.SetFocus
  6.     If Not IsNull(Originatorcmb) Then
  7.         ocxcalendar.Value = Originatorcmb.Value
  8.     Else
  9.         ocxcalendar.Value = Date
  10.     End If
  11. End Sub
Now the calendar needs to have focus:
Expand|Select|Wrap|Line Numbers
  1.  Private Sub ocxcalendar_Click()
  2.     Originatorcmb.Value = ocxcalendar.Value
  3.     Originatorcmb.SetFocus
  4.     ocxcalendar.Visible = False
  5.     Set Originatorcmb = Nothing
  6. End Sub
There is a caveate to all of this, the field from the table you are pulling your data needs to be a text field or you will get a data type mismatch error. Also, you will need to make the calendar not visable in the properties of the calendar under design.

Check out this thread of mine where I asked for help with the same question. There is some great info from Neopa.

http://bytes.com/topic/access/answer...-query-records

I hope all this helps.

MJA
Aug 6 '10 #5
NeoPa
32,567 Recognized Expert Moderator MVP
Thanks Michael. I'm glad you pointed me back there, as I found an error in my post when I looked it over again :D Sorted now.
Aug 6 '10 #6
f430
43 New Member
Thanks Michael, this calendar view solved the issues i was having with the date.
my other question is, since the "from" and "to" dates are a combo box, can i just treat it as any combo box code for my search. because my search form contains 3 combo boxes and the date (2 additional combo boxes).
in other words can i just use this type of a code:

Expand|Select|Wrap|Line Numbers
  1. Dim strFilter As String
  2. Dim varItem As Variant
  3.  
  4. strFilter = ""
  5. strQt = Chr$(34)
  6.  
  7. If Not IsNull(Me!ProductName) Then strFilter = strFilter & "[Product ID]=" & strQt & "*" & Me!ProductName & "*" & strQt
however, im not exactly sure how to make it search in between these two dates?
Aug 6 '10 #7
Michael Adams
55 New Member
Where are you putting your from and to values in your if not isnull statement?

I was doing a cdount for my search and this is what it looked like:
Expand|Select|Wrap|Line Numbers
  1. EADRcount = DCount("[type]", "WorkOrderTracking", "[workedby] = 'MJA' And [cudate] between '" & Me.fromdatecmb.Value & "' and '" & Me.todatecmb.Value & "'")
This code gave me a total count of all records for that date range.
[Type] = text field in the table
"WorkorderTrack ing" = the table
[workedby]='MJA' = search criteria limited to the employee matching MJA
between = operator used for the date range
"& me.fromdatecmb. value &" = the from value selected on the calendar
and = operator used for date range from 'and' to
"& me.todatecmb.va lue &" = the to value selected on the calendar

I hope this also helps.
Aug 6 '10 #8
f430
43 New Member
i was trying to get my search to filter a master table, which contains all the information such as date, part number,...and i am trying to make this date range one of the ways i could search through my master sheet.
Aug 6 '10 #9
f430
43 New Member
i am not really very familiar with this coding language, so i am not really sure how to make a code for a combo box for my search
Aug 6 '10 #10

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

Similar topics

2
2233
by: misschristalee | last post by:
I'm having a brain blockage day.... Scenario: Search Form with 6 text boxes Query has same six fields Each has this IIF: IIf(IsNull(!!),"",!!) with each dictating the correct text box of course. SQL dictates... If text box 1 isNull do nothing or do this OR if text
3
2177
by: Liddle Feesh | last post by:
Hi, I have a table named "Person" in a MSDE (2000) database, and am building a search form comprising of search fields on the top section (forename, surname, telephonenumber, etc) which all correspond to columns to search in the database. I'm relatively new to ADO.net and haven't the foggiest about where to start, and need a good example to take apart and learn relatively quickly.
7
3175
by: jim Bob | last post by:
Hi, This is probably very simple to do so if anyone can point me to the right place for reading, it would be much appreciated. I just want to build a very basic search form where i can enter a name or part of a name into a text box, press a button, and the entered value gets inserted into a sql query and the results of the query gets displayed into a list or text box. (ie take the input from the text box and plug that variable in my...
1
402
by: Eddie Holder | last post by:
Hi Guys, I hope that someone will be able to help I have a table containing data, lets say products. I have a form with a text box which serves as the criteria for a query to search the product name I would like the form and the query to work as follows If a leave the field blank on the form, it should return all the data from the table
31
2924
by: DWolff | last post by:
I'm somewhat new to Access, and have no VB experience at all (except for modifying existing code where obvious). I built a data entry form that works fine. Typically, a client will call in and the user has to find his record to add or modify existing data. Originally, I built the form based on a query with an input criteria for the last name and first name. The Last_Name critera is Like &"*" so that partial names will work. The...
9
16087
by: lightning | last post by:
Hi all, I'm not very conversant with the vocabulary of Access, so please ask for clarification if necessary... I am trying to build a search form that allows combinations of search terms. For example, let's say I have three controls on my form; year, keyword, location. Entering a valid value for all three gives expected results from the dataset. However, I'd like to interpret a blank field in the search form as ignoring that constraint....
6
2422
by: KiwiGenie | last post by:
Hi..I am trying to make a search form. I am fairly new to access and could well be looking at it completely wrong. I have an unbound form with textboxes in the header for entering different search criteria. I have a subform for displaying the results, which is bound to Query4. SQL for Query4 (taken from sql view in query): SELECT tblRecipes.RecipeName, tblRecipes.FoodCategory, Sum(Query3.IngredCost) AS SumOfIngredCost, Query3.RecipeID FROM...
1
2541
by: tamoochin | last post by:
I have a form that registers the user with my website, the form is in farsi language and must use utf-8 standard. I can store data in MS Access and also read it back with any problems. the characters are correct in database too. but when I want to search a user in my asp search form, the "not found" phrase displayed! any keyword I use to search like username or name or city will fail. but when I edit the user profile with my asp edit...
2
2260
by: Mark | last post by:
Hi All, I am creating a music database for a friend and have run into a problem. Within the ALBUM table, I wanted to store the ARTIST_ID rather than the ARTIST_NAME. To do this, I intended to have have a command button on the album form which would open a search form (based on the artist table). This works as I wanted and allows me to get to one record. I then planned to have a button on the search form which when clicked, would updated...
8
4520
by: munkee | last post by:
Hi everyone, I am using the following code adapted from Allen Browne: 'Purpose: This module illustrates how to create a search form, _ where the user can enter as many or few criteria as they wish, _ and results are shown one per line. 'Note: Only records matching ALL of the criteria are returned. 'Author: Allen Browne (allen@allenbrowne.com), June 2006. Option Compare Database
0
8268
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8202
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5575
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2628
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1812
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.