Access db help needed.

  • On a form, I want a price to automatically display when I select an item.

    For example.

    In a combo box, I would have a selection of camera gear that would incur a rental fee based on their rental type (Weekly Hire, Weekend hire, Overnight hire etc).

    Instead of having a user select both the camera gear and then select the rental type and price in another combo box ... how can I have it so that when the user selects the camera item, it will automatically display the rental fee?

  • oh, or do I create another table for "price"??

  • You answered your own question....

  • I don't think the answer is to create another table. The creation of tables is dependant on the relationship. If 1:1, then another table is not the answer.

    You should be looking at a combination of the after update event on the combo box that has somekind of DLookup, the answer of which then populates whatever you want to display the rental cost.

  • You don't even need to use DLookUp. If the price is in the same table or query than the one used as the RowSource for the combo (and if it's not you can always add it to the query), add the price column to the combo (you can make this column invisible through the ColumnWidths property), then fetch the contents of the price column in the AfterUpdate event of the combo by addressing it directly.

    Ex.

    Combo0

    -RowSource:

    SELECT Table2.Id, Table2.Price, Table2.Description

    FROM Table2

    ORDER BY Table2.Description;

    -ColumnCount: 3

    -ColumnWidths: 0,0,1.5 (inches)

    -Code:

    Private Sub Combo0_AfterUpdate()

    Me.Text1.Value = Me.Combo0.Column(1)

    End Sub

    Have a nice day!

  • I agree that the above is an even better solution than I had proposed.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply