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

How to create a search form using combo box's, txt box's, and view report

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 detail of what was found.I found this code (http://bytes.com/topic/access/answers/879487-question-about-form) and modified it for my needs. I tested the code and i got it to work for 2 text boxes, when i changed it to combo boxes, i received an error.

So, my question is, how to i complete what needs to be done. I know I'm at the beginning but i need to get this done.

Expand|Select|Wrap|Line Numbers
  1.  Dim strStudentRef As String
  2.         Dim strSearch As String
  3.        Dim strSql As String
  4.  
  5.     'Check Search Form for Null value or Nill Entry first.
  6.         If IsNull(Me![cmboOB]) Or (Me![cmboOB]) = Null Then
  7.         If IsNull(Me![cmboCN]) Or (Me![cmboCN]) = Null Then
  8.             MsgBox "Nothing Entered!", vbOKOnly, "Blank!"
  9.          Me![cmboOB].SetFocus
  10.      Exit Sub
  11.    End If
  12.    End If
  13.    '---------------------------------------------------------------
  14.  
  15.    'Performs the search using value entered into txtSearch
  16.    'and evaluates this against values in Address
  17.  
  18.        DoCmd.ShowAllRecords
  19.                                                  'Chr(42)is ascii code for the wildcard symbol
  20.        strSql = "Select * from [tblDocument] Where |related field for cmboOB| & |related field for cmboCN| Like '" & Chr(42) & Me!cmboOB & Me!cmboCN & Chr(42) & "';"
  21.        Me.RecordSource = strSql
  22.  
  23.        'If one or more matching records are found, they can be displayed one at a time via the navigation buttons
  24.        If Me.Recordset.RecordCount > 0 Then
  25.  
  26.            cmboOB.SetFocus
  27.            strSearch = cmboOB.Text
  28.  
  29.            cmboOB.SetFocus
  30.            strSearch = cmboOB & Space(1) & cmboCN
  31.            MsgBox "Match Found For: " & strSearch & " ", _
  32.                , "Found!"
  33.                cmboOB.SetFocus
  34.            cmboOB = Null
  35.            cmboCN = Null
  36.  
  37.  
  38.        'If value not found sets focus back to txtSearch and shows msgbox
  39.        Else
  40.            cmboOB.SetFocus
  41.            strSearch = cmboOB & Space(1) & cmboCN
  42.            MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
  43.                , "Sorry"
  44.                cmboOB.SetFocus
  45.        End If
  46. End Sub
  47.  
  48.  
  49.  
  50.  
  51.  
Thanks
Apr 5 '10 #1
6 3545
Delerna
1,134 Expert 1GB
what was the error and which line does it occur on?
Apr 6 '10 #2
The error is "The text you entered isn't an item in the list" for both combo boxes. The error doesn't take me to a line of code
Apr 6 '10 #3
Delerna
1,134 Expert 1GB
Are the combo boxes bound to a table or query?
or
did you manually enter a list of values when you created the combo box?

When you drop down a combo box you see a list of values from which you can select.
Alternatively you can type a value into the text section of the combo box but the value you type must exist in the list of values that you see when you drop it down.

Thats what the error is telling you. The value you entered isn't in the list.
I'm guessing that when you drop the combobox down the list is empty
because you haven't given it one and that's why it's not working.
Apr 6 '10 #4
Thanks, bound two of the 11 combo boxes to test it. The search worked but a pop up said "match not found for: 58 74 - Please try again"

Why am i getting that pop-up if the info is in my table?
Apr 7 '10 #5
Delerna
1,134 Expert 1GB
First thing I ask in that situation is

Are there spaces on the end of one and not on the end of the other
For Example
"58 74" will not match "58 74 "
even though they look the same (when you remove the quotes)


Next thing
Data in a field in access can sometimes (somehow ????) contain erroneous carriage returns
Try going to that record in the table and clear that field by pressing delete and backspace numerous times. Then re-enter the data.
Apr 8 '10 #6
There are spaces at the end of both sets of numbers.

I'll try your suggestion on clearing the fields but they look correct.
Apr 8 '10 #7

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

Similar topics

1
by: Dalan | last post by:
I designed a dialog box with a combo to select individual vendors from a form and its related data for print ouput. Though the dialog box seems to work okay, I apparently do not have the filtering...
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...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
6
by: fieldja | last post by:
I have a form called OwnerForm. It contains a combo box called Owner. The combo box looks up names from a table called OwnerName. It contains fields called OwnerID and Owner. I also have a main...
0
by: imwhiteandnerdy | last post by:
i'm kinda a newbie I would appreciate some help Basically i'm setting up a search page using multiple options from a combo box Combo Box(2 options) First Name Last Name text box to the...
3
by: suek | last post by:
I have a table with over 4000 records to search upon, and the users don't like a combo box. So what I have been trying to do for the last twelve hours is do some code to get a text box to search. ...
6
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate...
7
by: Ceebaby via AccessMonster.com | last post by:
Hi All Here's hoping someone can help me with this. I have a report based on a query where the criteria for 4 of the fields is set from an unbound form. I want the user to be able to select any...
2
by: yogeshtiwarijbp | last post by:
Hi All, Iam new in asp.net 2003 and sql server. I have to create an application having following criteria. Proposed Steps 1. Create a table containing fields as Name of Report, View Name or...
10
by: vanlanjl | last post by:
I have created a form that contain two combo boxes and two cmd buttons. The idea of the form is that the user will select a search parameter from each combo box then will click the first cmd button...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.