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

Form to Search and Retrieve Records

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 7476
puppydogbuddy
1,923 Expert 1GB
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
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 Expert 1GB
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.YourSubformControl.Form.RecordSource = strSql
Oct 29 '08 #4
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.YourSubformControl.Form.RecordSource = 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
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...
3
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...
3
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)...
4
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...
2
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...
13
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...
2
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...
2
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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...
0
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...
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.