473,657 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

combo boxes

I would like some help on the use of combo boxes.
I have created a form and named it Customers. This form's record
source is a table, also named Customer.
I would now like to add an unbound combo box, name it cbosearch, which
would return a selected record in a textbox, which I will name
txtresult.

The cbosearch record source is another table named AGENCIES which has
two fields: TOWN and ADDRESS.

I would that my cbosearch, will display only one field, TOWN (so that
I can see all Towns in the list) and on the OnChange event, display in
the txtresult, the second field: ADDRESS.

Can any one help me with the code?
Nov 12 '05 #1
1 2670
Can more than one address be in the same town? If so a simple textbox for
your result wont quite do the trick. If only 1 agency per town then this
would work

Note: This routine makes use of DAO (you will have to create a reference to
this library "Microsoft DAO 3.5". (maybe someone else could post an ADO
equivilent so you dont have to make a reference, my ADO is rusty yet and I
wouldnt want to miss-lead you)

put the following code behind a button that you place on your form, we'll
call it "Search" and we'll name our combo box "cboSearch"
<aircode>
Dim rs as Recordset
Dim strSQL As String

strSQL = ""SELECT ADDRESS FROM AGENCIES WHERE TOWN='" & cboSearch.Value
& "'"
Set rs = CurrentDB.OpenR ecordset(strSQL ,dbOpenSnapshot )
If rs.EOF And rs.BOF Then
Msgbox "No Matching Address for the selected town!",vbOkOnly ,"No
Match"
Else
txtresult = rs.Feilds("ADDR ESS")
End If
'lets be good programmers and clean up our mess after we make it :)
rs.Close
Set rs = Nothing
</aircode>

The idea here is to do it all in code since we are dealing with unbound
controls, first I create an sql query that will select the address from the
agencies table with a matching town to what the user selected. I placed a
little bit of error handling so you could see how to react for bad entries
(just in case your combo box is not set to "limit to list") if the .EOF and
..BOF flags are true then no records were returned. Otherwise we found a
result, we are _assuming_ one agency for one town. At that point simply
retrieve the value of the ADDRESS field and assign it to our txtresults
textbox. Finally, becuase we are dealing with recordsets, I close it and
free it from memory (I believe its better _not_ to get in the habbit of
letting Access clean up memory usage.) Thats it, we now have our results
for the user to see.

HTH

Mike Krous
"Paolo" <jp***@tin.it > wrote in message
news:9f******** *************** ***@posting.goo gle.com...
I would like some help on the use of combo boxes.
I have created a form and named it Customers. This form's record
source is a table, also named Customer.
I would now like to add an unbound combo box, name it cbosearch, which
would return a selected record in a textbox, which I will name
txtresult.

The cbosearch record source is another table named AGENCIES which has
two fields: TOWN and ADDRESS.

I would that my cbosearch, will display only one field, TOWN (so that
I can see all Towns in the list) and on the OnChange event, display in
the txtresult, the second field: ADDRESS.

Can any one help me with the code?

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4304
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
1
3316
by: FZ | last post by:
Hi Gang, I was wondering if a generous person might be able to walk me through what I believe is a pretty simple task. I actually have significant Access experience, but I haven't done it in about 3 years and I'm more rusty than I thought I was. Anyway, in a nutshell: The scenario: 2 combo boxes (comboLastName and comboStateorProvince) on a form with 30 text boxes, the form's recordsource has been set to a query, both combo boxes and...
0
3522
by: Krisa | last post by:
Hello all, I just discovered something (stop me if you've heard this before....) that was causing me a significant performance hit when opening a form with subforms. To speed up loading the form, I set the rowsources of its, and its subforms', combo boxes in the "Enter" events of the combo boxes. That's the standard trick for not loading the rowsource unless/until the user actually needs the combo box. For example:
0
1595
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number of text and combo boxes on it (in panels on the tab). These combos were originally simple drop down lists - i.e. you had to select from the list and couldn't enter anything of your own. At that time everything worked fine. Now, the users...
5
3693
by: jjyconsulting | last post by:
Newbie needing some help. I have a tblParticipants. The fields include gender, education_level, income, occupation etc., I'm trying to create a form where a user can run a query from the form and just choose the appropriate criterias from the combo boxes to get the results. I also want the query to run even if there is not a value in all the combo boxes ie., i want just all males with income level of over $100,000...Any insights or help...
4
2359
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. The idea behind the database is for a user to search/ select desired information in any kind of combination between the 4 combo boxes. Then the user clicks a button (btnSearch) and subsequently a query ("Search Function") is run that shows all 4...
6
3674
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
1
2905
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a main form (RD Form) with 4 combo boxes (i.e. cbo1, cbo2, etc) and a subdatasheet (the subform...let's call it subInfo) below the combo boxes on the RD Form. I hope this eliminates any confusion of the
2
3267
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once selecting from the combo box, I have all the combo boxes, using afterupdate, populating their respective list boxes. These text boxes are directly correlated to the combo box selection using SQL. Here is an example from the afterupdate event in the...
2
2296
by: someshbakliwal | last post by:
Hi, I have created some autopopulating combo boxes on my HTML page (script- Javascript). so these combo boxes are autopopulated with choices made in previous combo boxes. The problem I am facing is that the combo boxes resize according to the length of the autopulating string. For example if the combo box autopopulates with option 'United States of America', the combo box will become wider and if it autopopulates with value 'NY' the combo box...
0
8421
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
8742
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...
1
8518
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,...
1
6177
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
5643
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
4173
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
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.