473,563 Members | 2,805 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 2665
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
4295
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
3310
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)...
0
3512
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...
0
1588
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...
5
3685
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...
4
2355
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...
6
3669
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
2901
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...
2
3262
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...
2
2293
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...
0
7665
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...
0
7583
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...
0
7888
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. ...
0
8106
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...
0
6255
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...
1
5484
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...
0
5213
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...
0
3643
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...
1
1200
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.