By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,570 Members | 970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,570 IT Pros & Developers. It's quick & easy.

How to calculate a field based on the value of the other field

P: 14
I have an access form. In the form, it co ntains 3 fields : Type, hours, and Amount.

Field "Type" is a combo box and it contains 2 values: Standard and Rush
Field " Hours" is just a numeric field
Field "Amount" is a currency field.

What I try to do is if the user select Standard from the field "Type", the field "Amount" will be automatically populate by: 24*[hour], else if the type is "Rush" then the Amount field will be as 26*[fhours]

I am not to sure how to start and I would appreciate for any help. Michelle.
Dec 10 '06 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,627
I have an access form. In the form, it co ntains 3 fields : Type, hours, and Amount.

Field "Type" is a combo box and it contains 2 values: Standard and Rush
Field " Hours" is just a numeric field
Field "Amount" is a currency field.

What I try to do is if the user select Standard from the field "Type", the field "Amount" will be automatically populate by: 24*[hour], else if the type is "Rush" then the Amount field will be as 26*[fhours]

I am not to sure how to start and I would appreciate for any help. Michelle.
'This should work nicely:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboType_AfterUpdate()
  2.   Select Case Me![cboType].Value
  3.     Case "Rush"
  4.       Me![txtAmount] = 26 * Me![Hours]
  5.     Case "Standard"
  6.       Me![txtAmount] = 24 * Me![Hours]
  7.     Case Else
  8.   End Select
  9. End Sub
Dec 10 '06 #2

nico5038
Expert 2.5K+
P: 3,072
I nice workaround might be to change your combobox source into a two field valuelist like:
24,"Standard",26,"Rush"
Now also change the number of columns to 2 and set the columnwidth to 0 (zero) as that's suppressing the first column with the 24 and 26.
Also make sure that the bound column is set to 1.

Now the control sorce of field txtAmount can be set to:
=NZ([Type])*[Hours]

Idea ?

Nic;o)
Dec 10 '06 #3

P: 14
Thanks guys . It works wonderfully. Michelle
Dec 10 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.