473,406 Members | 2,867 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,406 software developers and data experts.

Fill in Text boxes based on Query results?

283 100+
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 2394
MOCaseA
34
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 100+
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
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, 210 views)
Sep 27 '10 #4

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

Similar topics

2
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...
2
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...
1
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...
5
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;...
2
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...
4
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...
2
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...
1
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...
1
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...
1
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...
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: 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?
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
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
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,...
0
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...

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.