Connecting Tech Pros Worldwide Forums | Help | Site Map

Combox Box -Help Please

Newbie
 
Join Date: Nov 2008
Posts: 26
#1: Apr 3 '09
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.

DonRayner's Avatar
Expert
 
Join Date: Sep 2008
Location: Canada
Posts: 494
#2: Apr 3 '09

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
Newbie
 
Join Date: Nov 2008
Posts: 26
#3: Apr 3 '09

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  
DonRayner's Avatar
Expert
 
Join Date: Sep 2008
Location: Canada
Posts: 494
#4: Apr 3 '09

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.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#5: Apr 4 '09

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