Select CBO and autofill text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am working on a database which I would like for the user to make a
selection from a cbo named "Title/Description" and once selected, have the
"Purpose" field prefill with the corresponding Purpose for the selected
Title/Description. I never tried this before and not sure how hard it is. I
was going to use If, Else statements but there is about 75 Title/Descriptions
and Purposes. I was hoping for a way to put them in a table.

If possible, please simplify answer explaining how this needs to be
accomplished.

Thank you!!
 
Stockwell43 said:
I am working on a database which I would like for the user to make a
selection from a cbo named "Title/Description" and once selected, have the
"Purpose" field prefill with the corresponding Purpose for the selected
Title/Description. I never tried this before and not sure how hard it is. I
was going to use If, Else statements but there is about 75 Title/Descriptions
and Purposes. I was hoping for a way to put them in a table.


First, make sure the combo box's RowSource includes the
purpose field (and that the combo box's ColumnCount aggrees
with the number of fields).

Then, all you need to do is set the text box's ControlSource
to an expression likeL
=thecombobox.Column(x)

where x is the zero based number of the purpose field.
 
Hello,

I am working on a database which I would like for the user to make a
selection from a cbo named "Title/Description" and once selected, have the
"Purpose" field prefill with the corresponding Purpose for the selected
Title/Description. I never tried this before and not sure how hard it is. I
was going to use If, Else statements but there is about 75 Title/Descriptions
and Purposes. I was hoping for a way to put them in a table.

If possible, please simplify answer explaining how this needs to be
accomplished.

Thank you!!

Yeah, put them in a table. Tie the combo box to the table, maybe
showing both fields. In the combo boxes' afterupdate event put the
following code:

dim db as dao.database
dim rsTitle as dao.recordset
set db=currentdb()
set rsTitle=db.openrecordset("tblTitle",dbopendynaset)
rstitle.findfirst "[Title]='" & cboTitle & "'"
if not rsTitle.NoMatch then
txtPurpose=rsTitle![Purpose]
endif

See if that does the trick. Don't forget to rename your controls
accordingly.
 
Hi,

Thank you. It seems to work fine. I make a selection in the drop down and
the Purpose field populates with the correct purpose tied to the TitleDesc in
the CBO.

Now the problem I'm having is I see the TitleDesc in my main table but not
the purpose. I need to do a query so I can get them in a report. How do I do
this?

Thanks!
 
Hi,

Thank you. It seems to work fine. I make a selection in the drop down and
the Purpose field populates with the correct purpose tied to the TitleDesc in
the CBO.

Now the problem I'm having is I see the TitleDesc in my main table but not
the purpose. I need to do a query so I can get them in a report. How do I do
this?

Thanks!







- Show quoted text -

It sounds like when you save the record, that the Purpose field isn't
being updated. Is it not linked? If the Purpose field was left out
of that table, you could create a query using an INNER JOIN on both
tables to create a composite recordset for the report.
 
Before you start testing a report, you need to create and
test a query to use as its record source. In this case, I
think all you need to do is Joint both the main table and
the same table used in the combo box's row source query.

After you get the query to retrieve the desired data, then
work on the report.
 
Back
Top