Query & combo boxes

B

BC

I want to use a query to add records a table ... I will call it 'Table1'
The records I want to add will be based on a 'FileNumbers' that is also
contained in another table ... I will call it 'Table2'
I want to use 'Table 2' as a means of knowing what are valid
'FileNumbers' and as such only allow a FileNumber to be entered that is
also contained in 'Table2'.
I would like to use a ComboBox to scroll though the valid 'FileNumbers'
(from 'Table2') as well as displaying some associated data (also from
'Table2') to show that it is the file number that I am interested in. I
do not want to allow changes of any of the displayed data from 'Table2'
including the FileNumber.
I would like however, to have the 'FileNumber' automatically go into a
TextBox that will be part of the new record being added to 'Table1'

Can this be done? .... Please give plently of details ... 'new' at
Access but 'old' in life.
 
M

Mark Phillipson

Hi,

If you set the ComboBox's RowSource to select the required columns from
Table2 and set the Limit to List Property to Yes then only existing values
can be selected.

To set the value selected into a text box enter code like the following in
the ComboBox AfterUpdate Event:

Me.txtName = me.cboComboBox

or if FileNumer is in the second column:

Me.txtName = me.cboComboBox.Column(1)

To prevent the value from being changed in the TextBox set it's Locked
property to Yes.

HTH


--

Cheers
Mark

Free Access/Office Add-Ins at:
http://mphillipson.users.btopenworld.com/
 
B

BC

I cannot seem to get it to work.
I placed two text boxes near the ComboBox in a attempt to display two
other fields from table2 as I scrolled through the FileNumbers ... they
did not work.
 
D

Douglas J. Steele

It doesn't work while scrolling through the combobox, only once you've
selected a row from the combobox.

However, the Access combobox can show multiple columns when it's open, so I
don't see why you'd need to show related values in a text box while
scrollling.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top