473,661 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form to Search and Retrieve Records

9 New Member
Hi Guys, I am trying to create a form which allows the users to retrieve records based on the values entered or chosen in the various combo boxes and textboxes, such as the customer's name, invoice number, service number and installation site. The users do not have to enter all the information for the search.

Currently, for the Customer's Name Combo Box, the values are retrieved from the Information Table and when a user selects a name, the Invoice Number Combo Box will automatically generate a list of Invoice Numbers related to the customer.



As for now, I need some guidance regarding the codes for the Search Button to retrieve the records. For example, when a user selects a particular Invoice Number and clicks on the Search Button, that particular Invoice Record will be shown.

Additional Information:
Tables:
1) Information (customer's particulars)
2) Invoice
3) SiteSurvey
4) ServiceRec (customer's service records)\

Queries:
1) infoInv (displays the fields in the Information table and Invoice table)
2) infoSs (displays the fields in the Information table and SiteSurvey table)
3) infoServrec (displays the fields in the Information table and Servicerec table)

Form: Single View, Unbound

Thanks!
Oct 29 '08 #1
4 7539
puppydogbuddy
1,923 Recognized Expert Top Contributor
Currently, for the Customer's Name Combo Box, the values are retrieved from the Information Table and when a user selects a name, the Invoice Number Combo Box will automatically generate a list of Invoice Numbers related to the customer.

As for now, I need some guidance regarding the codes for the Search Button to retrieve the records. For example, when a user selects a particular Invoice Number and clicks on the Search Button, that particular Invoice Record will be shown.

Form: Single View, Unbound

Thanks!
Here is sample code. Replace illustrative object names with their actual names in your application. Eliminate one of the two sql strings depending on the data type of the invoice. Assumes search results returned to main form because you did not mention anything about subforms.

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSearch_Click()
  2.  
  3. Dim strSql As String
  4.  
  5. strSql = "Select * From tblInvoice Where InvNo = " & Me!cboInvoice      'if InvNo is Numeric
  6.  
  7. strSql = "Select * From tblInvoice Where InvNo = '" & Me!cboInvoice & "'"      'if InvNo is Text
  8.  
  9. Me.RecordSource = strSql
  10.  
  11. End Sub
Oct 29 '08 #2
Evanescent
9 New Member
Here is sample code. Replace illustrative object names with their actual names in your application. Eliminate one of the two sql strings depending on the data type of the invoice. Assumes search results returned to main form because you did not mention anything about subforms.

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSearch_Click()
  2.  
  3. Dim strSql As String
  4.  
  5. strSql = "Select * From tblInvoice Where InvNo = " & Me!cboInvoice      'if InvNo is Numeric
  6.  
  7. strSql = "Select * From tblInvoice Where InvNo = '" & Me!cboInvoice & "'"      'if InvNo is Text
  8.  
  9. Me.RecordSource = strSql
  10.  
  11. End Sub
Hi. Thanks for replying. Ive added in the codes for the Search Button and there is no error message when I click on the button. If I were to include a subform to display the records, how do I go about writing the codes?
Oct 29 '08 #3
puppydogbuddy
1,923 Recognized Expert Top Contributor
Hi. Thanks for replying. Ive added in the codes for the Search Button and there is no error message when I click on the button. If I were to include a subform to display the records, how do I go about writing the codes?
To display the records on the subform instead of the main form, change Line No 9 in the above code as follows:

From this:
Me.RecordSource = strSql

To This:
Me.YourSubformC ontrol.Form.Rec ordSource = strSql
Oct 29 '08 #4
Evanescent
9 New Member
To display the records on the subform instead of the main form, change Line No 9 in the above code as follows:

From this:
Me.RecordSource = strSql

To This:
Me.YourSubformC ontrol.Form.Rec ordSource = strSql
Thanks a lot for your help!
Oct 29 '08 #5

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

Similar topics

2
5964
by: Iain Miller | last post by:
Now this shouldn't be hard but I've been struggling on the best way as to how to do this one for a day or 3 so I thought I'd ask the assembled company..... I'm writing an application that tracks a group of Sales people, the customers they deal with and the business they transact with them. I've got my head around all the tables & some of the basic Query structures OK and am beginning to delve into creating the forms I need to be able...
3
2794
by: Simone | last post by:
Hi All, I have a Find Record button setup in most of my forms in order to find a specific customer's details. I have just noticed today though that this search will only find the customer if it already has linked data in the subform. This totally defeats the purpose of my search, which is to find an existing customer's details in order to enter new data in the subform. I was wondering if there is a way, in the form/subform situation,...
3
2589
by: Chris | last post by:
Before I started to create table, etc to track unique form field record number assigments I thought I'd check to see if there is now a better way to do this in .NET. I have a parent form (table) and children form (table). Relationship equals one to many. I'd like to auto number the fields accordingly and traditionaly I assign a unique number based on a table value that I retrieve + 1. i.e. Parent record field value = 1 Children record...
4
3500
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I click a button on a pop-up window the javascript for that button click does a 'button.form.submit'. On the Server side there is a Button click event for this button, but for some reason it no longer fires. It worked fine before and everything...
2
6332
by: allyn44 | last post by:
Hello, I have built a serch form for users to edit records. I only want them to pull up the record they need, and I want to check for nulls. There should not be dupes becasue the underlying tables are indexed. So the user will pull up either one record or none. Here is my problem: I pass the form name through a tmpvariable and ther other search parameters through unbound fields on an unbound form--this works fine unless the form opens...
13
3422
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end of the form which is submit and cancel. After i have clicked submit, the information is stored directly into my corresponding database table. My problem here is i need to retrieve back the information submitted to display all the data that the...
2
3201
by: kev | last post by:
Hi Folks, I have created a search query in which it successfully returns correct results. When there are no records returned, instead of giving out a blank form i created a pop-up msg which is attached to the On Open event. However, right after the msg box pops saying"no records", this is followed by another msg box with "TheOpen Form action was cancelled". Is there a way i can eliminate the second msg box from appearing?
2
1341
by: gilsygirl | last post by:
Hi Good guys I am a newbie in VB 6.0. I want to retrieve records from a database. I want to use three fields from the database as a key to retrieve a record and post this record details to a second form. This what i have for the time being: Public Sub cmdCheckRest_Click() Dim Key_Fld As String
3
5391
by: Redbeard | last post by:
Hi All this is my first time post, be gentle. I am looking at creating a keyword search that searches multiple fields in a Form and then filters records that match the keyword. The Form currently has a button that connects to a Query that run the keyword search in several field and then filters the results. The problem is that I can not do a search within a search, or have multiple words searched in any order. For example there are 20,000...
0
8428
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
8341
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,...
0
8851
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, 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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8754
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8630
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7362
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
6181
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
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1984
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.