473,698 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fill in Text boxes based on Query results?

283 Contributor
Hello,

Im having trouble getting a form to fill in mulitple text boxes based on a query.

What I have is a form where I can enter the Criteria information to look up a record. You have to enter the information in to 3 text boxes on the form. Then after your done a query will run pulling up the results. That part seems to work with no problem but what i cant get to work is instead of the query window popping up, have all of the the other text boxes on the form fill in with the information.

I was thinking I might have to change all of my text boxes to list boxes but not sure if that would be the best approach?? Also after the information fills in i need to be able to edit the information, if i can do that with a list box then maybe that is the best approach.

Any help would be great!

Thanks in advance :D
Sep 25 '10 #1
3 2411
MOCaseA
34 New Member
Let me see if I have this straight. You are trying to create a record look up based off the information typed into a series of text boxes. You also want to be able to edit the information on the record that you look up. Correct?
Sep 27 '10 #2
slenish
283 Contributor
yes you are correct, but the information from the query I want to populate a form. Then you can edit the information on the form and then re-save it.
Sep 27 '10 #3
MOCaseA
34 New Member
Try something like this:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Field1_AfterUpdate()
  4.     SetFilter
  5. End Sub
  6.  
  7. Private Sub Field2_AfterUpdate()
  8.     SetFilter
  9. End Sub
  10.  
  11. Private Sub Field3_AfterUpdate()
  12.     SetFilter
  13. End Sub
  14.  
  15. Private Sub SetFilter()
  16.     Dim FilterCriteria As String
  17.     If Field1 & "" <> "" Then FilterCriteria = FilterCriteria & " AND [Field1]='" & Field1 & "'"
  18.     If Field2 & "" <> "" Then FilterCriteria = FilterCriteria & " AND [Field2]='" & Field2 & "'"
  19.     If Field3 & "" <> "" Then FilterCriteria = FilterCriteria & " AND [Field3]='" & Field3 & "'" 
  20.     If FilterCriteria = "" Then
  21.             Me.FilterOn = False
  22.     Else
  23.         FilterCriteria = Mid(FilterCriteria, 6) 'REMOVE THE LEADING " AND "
  24.         Me.Filter = FilterCriteria
  25.         Me.FilterOn = True
  26.     End If
  27. End Sub
Do this by creating 3 Combo Boxes somewhere on your form. Relabel the "Field#" with the appropriate combo box name, then set your row source to the appropriate field on the associated table (you can use the Query Builder for this to make it easier). Make sure your control source properties are blank. Finally if you find you are generating huge lists of duplicate data in the combo boxes, or wish to avoid having this happen in the future change "SELECT" to "SELECT DISTINCT" in the row source. Also if you wish to avoid typos you can change the Limit to List property to "Yes."

This will create a series of 3 combo boxes that allow you to look up information. It's quick and dirty, and still allows for user error (Like if you select a name then a company which that name is not associated with in any record) but if you add it to your main data form, then you can filter your records down. Attached is a screen shot showing an example of how I implemented this.
Attached Images
File Type: jpg screen1.jpg (34.6 KB, 212 views)
Sep 27 '10 #4

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

Similar topics

2
1970
by: Joey | last post by:
Say a customer inserts into a sql database field (NUMINSERTS) the number 6. On the following page, I want to build a table that displays 6 input boxes, since the customer said they wanted 6 text boxes. I will then insert the data from the 6 text boxes back into another sql database table. For example:
2
2278
by: Jeff | last post by:
Hello All: What I am trying to do is bind a textbox (really several text boxes) based on a list box selection. Basically what I'm dealing with are two tables with a 1 to 1 relationship. I have created the dataset and defined the relationship between the two tables in the schema. I add a list box to a form and set it's datasource to the parent table and its
1
1998
by: Meaney | last post by:
Hi, I have a form with 4 combo boxes. They are used for selecting SchoolName (lists 28 names), LocationName (lists 4 geographic locations), EquipmentName (lists 14 equipment types) and ObservationNumber (lists count number 1-3). All of the the combo boxes contain two columns. The first column is visible and displays the common name that the user can identify. The second column is the bound column and is hidden. This column (2) lists the...
5
1605
by: tarscher | last post by:
Hi all, I create a set of text-boxes based on user input: for (int i = 0; i < Convert.ToInt16(keywordsDropDownList.Text); i++) { myTextBox = new TextBox(); myTextBox.Columns = 5; myTextBox.ID = "parameterTextBox"+Convert.ToInt16(i);
2
1743
by: fariba123 | last post by:
i have designed an employee information site. there is an option to generate pay slip. how can i show the employee related data based on the drop down list. i have found code example for managing list boxes. but i need help on managing multiple text boxes. please give a quick reaply. thank you
4
3507
waynetheengineer
by: waynetheengineer | last post by:
Hi, I was wondering if anyone had any suggestions on my database: I have a form that accepts user input into a single text box. When the OK button is hit, a query should search for all records that contain the user inputted text for a specific field in the query's criteria section. I want the criteria to search for any matching part of the word, for example: If the user enters in the text box: rabbit The query should return all...
2
1570
by: chaosdl | last post by:
Hello, I am currently using Visual Basic 2005 express edition with a MS Access database. I have made a "Contacts" Form, where the user will be able to enter a members surname and press an OK button, this then searches through the database and displays the results in the corresponding text boxes (ID, FirstName, LastName etc) of the searched member. I have used an SQL statement to search through the database, the problem I am having is filling...
1
1786
by: griffin700 | last post by:
hi, am working on building a form in MS ACCDESS: I have there some combos & some textboxes. I want to create a macro about behaviour of 3 of those: textbox1, textbox2 & textbox3 should be active if value from combobox = answer1 if it is so, I need also to make these 3 textboxes mandatory
1
1767
by: kickergirl | last post by:
I'm not sure my title actually describes my problem, but here it goes. I am creating a form to track account information for participants. Basically, a single participant can be offered up to $3,000 for the first year and up to an additional $3,000 for the second year. The main form tracks the dates the offers were made. And I have incorporated a subform to track the disbursements, whether for the first year allotment or second year...
1
3639
by: peasedm | last post by:
Okay this one has me stumped. I have a table called Review_Statements with the following columns: statementid type statement1 statement2 statement3 I have a form called SR_Review with an unbound combo box control
0
8668
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
8598
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
8885
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
7708
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...
0
5857
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
4358
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3037
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
2
2320
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.