hi, i have a master table with all my part information, and it has columns with part number, date, defects,...
and i am trying to write a code for my search form.
i have created a search form on Access, and it has 5 combo boxes for:
part number
defects
assembled by
and the other 2 combo boxes are for "from" and "to" date range. i have made the combo boxes for the date range to display a calendar when clicked and choose a date.
i have been trying to write a code that only requires one of these fields to be filled out and it can filter my master table.
i would appreciate any help on this
Thanks
61 3700 NeoPa 32,564
Recognized Expert Moderator MVP
Check out Example Filtering on a Form.
When you've had a play, let us know if there is anything you still feel unsure about. The more clear and specific you can be about what you're struggling with, the more quickly and easily we we be able to help you.
Thanks NeoPa for the info, the article provides some helpful hints. however i do have some questions about my code.
1) in my search form i have a date range, which is made up of a combo box at each "from" and "to" when they are clicked a calendar pops up and a date can be picked. my question in regards to this is, how can i do a search of my master table of any entry in between these 2 dates? because i believe that the code u provided above was only meant to pick the exact date entered.
2)in my second combo box, im trying to filter my master table according to the defect entered into the search. however in my master table i have 3 columns for defects (labeled defect 1, 2, 3)since some parts have more than one defect. how can i make my code search all 3 columns for the defect entered into the search field?
would it be something like this: - If Me!Defect > "" Then _
-
strFilter = strFilter & _
-
" AND ([Defect Code 1, defect code 2, defect code 3]=" & _
-
Me!Defect & ")"
thanks
one more thing. i have tried manipulating your code to fit mine, but since im using a command button for my search,nothing really seemed to work out. after i tried to fix everything to on click and saved, exited and ran the code. but it didnt work
NeoPa 32,564
Recognized Expert Moderator MVP f430: 1) in my search form i have a date range, which is made up of a combo box at each "from" and "to" when they are clicked a calendar pops up and a date can be picked. my question in regards to this is, how can i do a search of my master table of any entry in between these 2 dates? because i believe that the code u provided above was only meant to pick the exact date entered.
There is a Between X And Y construct in a SQL WHERE clause or filter. EG : - ...
-
WHERE [DateField] Between #1/1/2009# And #12/31/2009#
f430: 2)in my second combo box, im trying to filter my master table according to the defect entered into the search. however in my master table i have 3 columns for defects (labeled defect 1, 2, 3)since some parts have more than one defect. how can i make my code search all 3 columns for the defect entered into the search field?
would it be something like this: - If Me!Defect > "" Then _
-
strFilter = strFilter & _
-
" AND ([Defect Code 1, defect code 2, defect code 3]=" & _
-
Me!Defect & ")"
This is a good reason for not storing your data that way of course, but you could use (if exact matches were being looked for) : - strSQL = "SELECT ..." & _
-
"WHERE '" & Me.DefectCode & "' In([defect code 1], _
-
[defect code 2], _
-
[defect code 3])
NeoPa 32,564
Recognized Expert Moderator MVP f430: one more thing. i have tried manipulating your code to fit mine, but since im using a command button for my search,nothing really seemed to work out. after i tried to fix everything to on click and saved, exited and ran the code. but it didnt work
I can't really comment or advise on where you went wrong unless you show me what you've done. I'm clever I know, but not that clever :D
i keep getting an error when using this - strSQL = "SELECT ..." & _ "WHERE '" & Me.Defect & "'In([defect code 1], _ [defect code 2], _ [defect code 3])
once i write this statement and move to another line, it highlights [defect code 2] and says compile error:expected: end of statement.
also, im not sure what comes before the code you provided for the date range. and i am also assuming that this would look something like this: - WHERE [DateField] Between #fromcombobox# And #tocombobox#
i will post my complete code after i solve the current issues.
Thank you for your help.
NeoPa 32,564
Recognized Expert Moderator MVP
As the underline character (_) indicates line continuation, it is not valid to use it as you have within code on a line.
As for your Between code : - WHERE [DateField] Between #fromcombobox# And #tocombobox#
This is not quite correct as dates should be formatted properly for use in SQL (See Literal DateTimes and Their Delimiters (#)). It is pretty close otherwise though. It may even be that you have explicit formatting for the two ComboBoxes which is compatible with SQL. In that case it would not be so wrong to use the code you've posted (Personally I'd always reformat it explicitly, but that's a choice if the code is already working).
i have defined my from box as "date1" and to box as "date2"
i am not really sure what you mean by explicitly formatting these two boxes.
i was also wondering what kind of code i should use before the where statement.
Thanks
this is the code that i currently have, but it is giving me a lot of problems. i also have not included the code for my date range, because i am not quite sure how to build it. -
Private Sub cmdfindrecords_Click()
-
Dim strFilter As String, strOldFilter As String
-
-
strOldFilter = Me.Filter
-
-
If Me!productnum > "" Then _
-
strFilter = strFilter & _
-
" AND ([Part Number]=" & _
-
Me!productnum & ")"
-
-
-
strFilter = "SELECT ..." & _
-
"WHERE '" & Me.Defect & "' In([Defect Code 1], [Defect Code 2], _ [Defect Code 3])"
-
-
-
strFilter = "SELECT ..." & _
-
"WHERE '" & Me.associateid & "' In([associate], [associate 2])"
-
-
-
If strFilter > "" Then strFilter = Mid(strFilter, 6)
-
If strFilter <> strOldFilter Then
-
Me.Filter = strFilter
-
Me.FilterOn = (strFilter > "")
-
End If
-
-
-
End Sub
when i search using the part number, nothing happens.
when i search using either associate number or defect, i get an error msg: u cant assign a value for this object, and when i go to debug it highlights this code: Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
by: Sheau Wei |
last post by:
This is the search engine code that i create, but it was error and didnt come out the result. Cn u help me to check what wrong with my code?
Thanks
<Table cellspacing=1 cellPadding=1 align=center>
<td colspan=4>
<h2 align=center>Bomba inventory searching system</h2>
<tr>
<td>
<h4 Balai Bomba Inventory Searching System</H4>
<form...
|
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...
|
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...
|
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...
| |
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...
|
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 listbox for users to select and search for counties.
On the same page however I would like to integrate a similar multiselect box for nationality. I...
|
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 for 2 list boxes:- county and nationality, while trying to add a third multi select list box for qualifications search is where i encounter my...
|
by: mercout |
last post by:
Hey,
I've been trying to create a search form in access for a while now, searching through books and emails. I have the search form set up with 11 combo box's, 3 text box's, a view button, and a clear button. Once the user enters certain fields, all of the boxes do not have to be filled and clicks the view button, a report will pop up with...
|
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: ...
|
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...
| |
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...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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...
|
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...
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |