Form Fields

propolis

Registered User.
Local time
Today, 02:43
Joined
Jun 16, 2005
Messages
11
Hi,


I have a combo box which has the follwoing options:

Column 1 Column 2
1 Wedding
2 Funeral

Now you can select via the combo box and the field will be populated with that choice.

Now I have a additional field that needs to display the following.

If the combo field shows Wedding, then the addiditional field needs to show £200.00

If the combo field shows Funeral, then the addiditional field needs to show £100.00

:)
 
Combo

Take a look at the database projects that come with Access. Looking through these you will find quite a few examples of what you are trying to do along with other examples of form,query, table, and report design.
 
In the AfterUpdate event of the combo, add an If statement.

Code:
If Me.YourCombo = "Wedding", Then 
    Me.OtherField = 200
Else
    Me.OtherField = 100
End If

Make sure to set the Locked property to OtherField to Yes to prevent the user from changing the value.
 
Hi Pat,

Thanks for the information. It works fine.

Just wondered if you can advise since this is hardcoded, it cant be changed without going into the code builder.

Could I reference to a table to get the same result.

Cheers
Eddie
 
If the value is included in the table used as the RowSource for the combo, include the amount field in the query. You can hide it so it doesn't show. Then you only need a single line of code.

Me.OtherField = Me.YourCombo.Column(2)

Combos are zero based arrays so .Column(2) is actually the third column of the combo's RowSource. Adjust the number as necessary for your query.
 
Hi Pat,

No joy yet, but then its most likely im doing something stupid. Your last suggestion is what Im after, and when I get the price appear in the other field, I have to make sure it appears in the report as well.

Thanks for the suggestions

Eddie
 
Success at last. Walk away and then come back to have a look and its surprisingly how quickly you spot the error.

Eddie 8-)
 

Users who are viewing this thread

Back
Top Bottom