Automatically Insert Data into Form

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

Guest

Hi,

I have an Access database designed to create reciepts. The main form feeds
from two tables, one which all of the information is stored in and another
which is updated via quieries as this information is subject to change
(Contains Course Name and Cost , this information is taken from other tables
that contain specific courses and their details such as duration and
requirments). Is it possible to have the Course Cost to be automatically
inserted in the main form when the Course Name is selected from a drop down
box? This would be handy when creating reciepts.

The Course Name field is in a Combo Box and gets its data from the Course
table.

I have a Course Name and Course Cost in the main forms table but have no
idea how to make the connection between course cost and course.

My knowledge on Access is minimal, so this question is probably confusing to
read.

Any pointers would be greatly appreciated.

Thankyou.
 
Matt,

Open your form in design view, select the combo box and display the
properties window. Locat property Row Source on the Data tab, place the
cursor there and click on the little button with the three dots on the right
to invoke the query builder; you will be taken to a query design screen;
select the courses table (if not already there, and add the course name and
course cost fields to the grid; close the view confirming to save the SQL
statement. Back to your form, notice that the combo now displays the name
and the cost next to it.
Now select the control you want to display the cost in, and set its Control
Source property (on the data tab) to:

[cboCourse].Column(1)

replacing cboCourse with the actual name of the combo. This will make this
control display the second column (first has index 0) of the current
selection in the combo.

If you do not want the cost displayed in the combo, use its Column Widths
property (on tab Format) to set the second column width to 0; it will no
longer display, but the other control will still pick it up.

Note: this way the contropl displaying the course cost cannot be bound to a
table field (so you cannot save it), which I assume is not your intention
anyway; it may be used to display, print the form or be used in a
calculation in another control. If you need to save it to a table field, it
would take an additional step (you would have to use a simple macro or line
of code to set the value instead of using the Control Source property, so
the latter could be used to bind to a table field).

HTH,
Nikos
 
Back
Top