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

Details (Adress) in a textbox related to a selection in a combo

Hi all,
I have a database where i make a selection in a casacde combo. Problem is I want to see more details about last selection. My last combo is named cboLocations and I want to see in a text box named txtAdress the adress related to the Location selected in the combo. Also I'd like to have the textbox invisible until I've make a selection on combo.

Thank you in advance for your time and consideration.

Best Regards,

Dan
Jun 29 '11 #1
1 1265
Adam Tippelt
137 100+
For starters, in design view select your textbox, go into the Format tab and set its Visible property to No. This way it's automatically invisible, until a check is made later on to make sure that a value has been chosen.


If you're only looking to return a single cell value from a table, you could use a Dlookup to find the value:

For cboLocations, create an AfterUpdate event with the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboLocations_AfterUpdate()
  2.  
  3. Me.txtAddress = DLookUp("YourAddressColumn", "YourTableContainingTheAddressColumn", "[YourLocationColumn]='" & Me.cboLocations & "'")
  4. Me.txtAddress.Visible = True
  5.  
  6. End Sub
(Note the additional single quotes for text based fields)

One thing to note is that if you have multiple records with the same address, you'd need to make sure the Row Source of cboLocations includes the unique ID column (Change cboLocations Format so that Column count is 2, but ID column width can be 0cm if you don't want it visible in the combo box), and then change the DlookUp so that the criteria checks the ID column instead:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboLocations_AfterUpdate()
  2.  
  3. Me.txtAddress = DLookUp("YourAddressColumn", "YourTableContainingTheAddressColumn", "[YourIDColumn]=" & Me.cboLocations.Column(0))
  4. Me.txtAddress.Visible = True
  5.  
  6. End Sub
(Single quotes removed for integer-based fields)

If you intend on extended this so that it returns values from multiple columns (so an entire record as opposed to one column's value) you'd probably be better off making sure the form is bound to that table, and then using a Recordset to navigate the form to the designated record:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboLocations_AfterUpdate()
  2. Dim db as DAO.Database
  3. Dim rs as DAO.Recordset
  4.  
  5. Set db = CurrentDb
  6. Set rs = Me.RecordsetClone
  7.     rs.FindFirst "[YourLocationColumn]=" & Me.cboLocations    
  8.     If rs.NoMatch Then
  9.         MsgBox "No match.", vbExclamation + vbOKOnly
  10.     Else
  11.         Me.Recordset.Bookmark = rs.Bookmark 
  12.     End If
  13.  
  14. End Sub
The DLookUp method should suffice for now.

Hope that helps.

Adam.
Jun 29 '11 #2

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

Similar topics

2
by: Rob | last post by:
Hello, I am developing an A2K application.In the subform ,I have around 4 combo boxes for Group,Division,Name and Application.The selection criteria of each combo is narrowed based on the value of...
1
by: Access User | last post by:
Here is my situation: I have two tables linked together in a many-to-many relation through an interum table. It looks like this... Title TitleTopic Topic...
2
by: Inquiring_Mind | last post by:
i am creating a database. i have the following question.. as per the specs... i need to be able to pull other forms from the master form using either a list or a combo box. what is the...
2
by: Jeff Mason | last post by:
I'm observing some strange behavior when I use a bound combo box in conjunction with the combo's anchor property. I define a form which contains just a textbox and a combo box. The text box is...
4
by: rroman | last post by:
I have a drop downList being populated by a dataSet. My dataSet has the folliwing fields: (id, usersName, emailAddress). My dropDownList has the DataTextField set to usersName and the...
2
by: RICHARD BROMBERG | last post by:
I have a table which contains a City field and a Street field and some other fields. The main form has two combo boxes cmboCity and cmboStreet I want to select a city from then cmboCity combo...
6
by: slavisa | last post by:
I have one questions about my database. I have made couple of tables and some forms and a report. I have a table called CourseNumbers with 2 fields, one is the coursenumber (ex. CI-120) and other...
1
by: jlcash | last post by:
I have the following situation in Access 2003 I need some help on: I have a form that I would like to set up so that when a user selects a time (Quarter/Year) from a combo box, the next field, a...
0
by: hardieca | last post by:
Hi, I have created a treeview bound to a sitemap provider. I have put it into a user control (the control will be used for similar, but not always identical, functionality). The treeview...
4
by: Higgs | last post by:
Hello, If i have a table like this: U I AbsTime TypeOfFile 2 0.01 0000001 000001-D00 3 0.01 0000002 000001-D00 4 0.01 0000003 ...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.