Connecting Tech Pros Worldwide Help | Site Map

Combox Box -Help Please

  #1  
Old April 3rd, 2009, 05:19 PM
Newbie
 
Join Date: Nov 2008
Posts: 26
Hello There,

I have combo box and getting data from table.

I wanna read data from combo box and auto fill the text box when form open or load.

For Example:

Combo have three value a;b;c and wanna display a,b,c in text box (Continuous Forms) when open or load the form.

Is it possible? If so, Can you please help me to do it?

Thank you in Advance.
  #2  
Old April 3rd, 2009, 08:58 PM
DonRayner's Avatar
Expert
 
Join Date: Sep 2008
Location: Canada
Posts: 494

re: Combox Box -Help Please


OK, a few assumptions here,

1. You are using two forms
2. Combo box on the first form
3. Textbox on the 2nd form

In the on open event for the 2nd form you would place code along these lines. You will need to substitute MyTextBox, 1stFormName and ListBoxName with the actual names from your project.

Expand|Select|Wrap|Line Numbers
  1. Me.MyTextBox = Forms!1stFromName.Form!ListBoxName
  #3  
Old April 3rd, 2009, 09:45 PM
Newbie
 
Join Date: Nov 2008
Posts: 26

re: Combox Box -Help Please


Thank you for your reply.

My combobox and textbox in the same form.

Another question:

Have table with data ( like a,b,c,d in column 1), want to read data from table and put in text box in continuous form.

like tble name "tbltest" and textbox name "txtbox".

now want to read first data from table and put in text box, then read second one and put in text box .....so on unit finish data in table.

Try to write following code, but couldn't fiqure out ----" New in VBA"
Expand|Select|Wrap|Line Numbers
  1. Set db = CurrentDb()
  2. Set rsLoc = db.OpenRecordset("tbltest", DB_OPEN_TABLE)
  3. 'Loop through records
  4. rsLoc.MoveFirst
  5. While Not rsLoc.EOF
  6.  
  7. txtbox =
Thx

*Please check attachment*
Attached Thumbnails
snapshot.jpg  

Last edited by NeoPa; April 4th, 2009 at 10:19 AM. Reason: Please use the [CODE] tags provided
  #4  
Old April 3rd, 2009, 11:22 PM
DonRayner's Avatar
Expert
 
Join Date: Sep 2008
Location: Canada
Posts: 494

re: Combox Box -Help Please


Hi shimul,

If they are on the same form then the code would be. And you would place it in the after update event for your listbox.

Expand|Select|Wrap|Line Numbers
  1. Me.MyTextBox = Me.ListBoxName
As for your other question, I see that you have already asked it in another post so that's where I'll post back.
  #5  
Old April 4th, 2009, 10:25 AM
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,473
Provided Answers: 57

re: Combox Box -Help Please


Quote:
Originally Posted by shimul View Post
I have combo box and getting data from table.

I wanna read data from combo box and auto fill the text box when form open or load.
There are two possibilities here :
  1. The data you want to display is also in your Record Source (table or query). Solution is easy. You bind the TextBox control to the Field you want.
  2. The data is not available and you want it to reflect a value dependent on the value of the ComboBox control. IMPOSSIBLE.
You're struggling with this because it is the latter I expect. An unbound control on a continuous form can only ever store one item at a time. As it is not a bound control it is not perpetuated across the various records but is a single, form level item.
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display the combo box items babitha162 answers 7 March 26th, 2009 02:35 AM
Urgently need a reply: How do i filter a form using a combo box in another form viranadim answers 1 April 1st, 2008 07:03 AM
Recommendations for combo box control Hans Merkl answers 7 November 24th, 2005 09:25 AM
ComboBox Items Wayne Wengert answers 3 November 22nd, 2005 02:08 AM
ComboBox Items Wayne Wengert answers 3 July 19th, 2005 04:43 AM