472,341 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,341 software developers and data experts.

Updating a field's value based on another field

Hi all,

I was wondering if any of you guys can help me out with this:

I have two fields on a form: one field is Premium and the other is
Brokerage. Whatever amount is in the Premium field is multiplied by
10% in the Brokerage field. If I change the amount in the Premium
field, the Brokerage amount should change accordingly as well. I know
I can do this in a query with a simple calculation set up; however,
there are exceptions to the 10% rule. Therefore, I'll need the ability
to change the amount in the Brokerage field from time to time - with a
Query, that won't be possible. What is the easiest way to acomplish
what I want. I am a newbie so if you can provide me with step-by-step
instructions, it will be most appreciated.

Thanks!

Feb 21 '07 #1
4 28981
On Feb 21, 3:13 pm, "Haas C" <haas...@yahoo.comwrote:
Hi all,

I was wondering if any of you guys can help me out with this:

I have two fields on a form: one field is Premium and the other is
Brokerage. Whatever amount is in the Premium field is multiplied by
10% in the Brokerage field. If I change the amount in the Premium
field, the Brokerage amount should change accordingly as well. I know
I can do this in a query with a simple calculation set up; however,
there are exceptions to the 10% rule. Therefore, I'll need the ability
to change the amount in the Brokerage field from time to time - with a
Query, that won't be possible. What is the easiest way to acomplish
what I want. I am a newbie so if you can provide me with step-by-step
instructions, it will be most appreciated.

Thanks!

In the after update event for Premium add code.

if isnull(me.premium) then
me.brokerage = 0
else
me.brokerage = me.premium * .10
endif

I would suggest that you put that .10 in some table somewhere, and
change your code to something like this

(again in the afterupdate)
actPercent = dlookup ("[tblPercent]", "Query that gets percent from
table")
if isnull(me.premium) then
me.brokerage = 0
else
me.brokerage = me.premium * actPercent
endif

And use that method whereever you might change the value. That way
you don't have to hunt down all the places when the percentage goes
to .12 - just change the table entry.

Ron

Feb 21 '07 #2
On Feb 21, 5:13 pm, "Haas C" <haas...@yahoo.comwrote:
Hi all,

I was wondering if any of you guys can help me out with this:

I have two fields on a form: one field is Premium and the other is
Brokerage. Whatever amount is in the Premium field is multiplied by
10% in the Brokerage field. If I change the amount in the Premium
field, the Brokerage amount should change accordingly as well. I know
I can do this in a query with a simple calculation set up; however,
there are exceptions to the 10% rule. Therefore, I'll need the ability
to change the amount in the Brokerage field from time to time - with a
Query, that won't be possible. What is the easiest way to acomplish
what I want. I am a newbie so if you can provide me with step-by-step
instructions, it will be most appreciated.

Thanks!
Take a look in the help files for a topic called or similar to "Set
the value of a control based on the value of another control by using
Visual Basic". You'll probably want to apply what you learn to the
Premium fields AfterUpdate event.

Feb 21 '07 #3
On Feb 21, 3:13 pm, "Haas C" <haas...@yahoo.comwrote:
Hi all,

I was wondering if any of you guys can help me out with this:

I have two fields on a form: one field is Premium and the other is
Brokerage. Whatever amount is in the Premium field is multiplied by
10% in the Brokerage field. If I change the amount in the Premium
field, the Brokerage amount should change accordingly as well. I know
I can do this in a query with a simple calculation set up; however,
there are exceptions to the 10% rule. Therefore, I'll need the ability
to change the amount in the Brokerage field from time to time - with a
Query, that won't be possible. What is the easiest way to acomplish
what I want. I am a newbie so if you can provide me with step-by-step
instructions, it will be most appreciated.

Thanks!
Haas:
Here is some code I've used in one of my forms, modified (I think) to
your needs. It leaves the Brokerage field editable in the event you
want to manually change it. Go to the properties of your Premium
field on your form. Click on the Event tab and select [Event
Procedure] in the After Update box. Then, click on the button with
the ... to the right of the After Update box and paste this where it
dumps your cursor:

Dim Response
Dim Msg as String
Dim Title as String

If IsNull(Me!Premium) Then
Msg = "Would you like to reset the Brokerage amount for this
record to zero?"
Title = "Reset Brokerage Amount?"
Response = MsgBox(Msg, vbYesNo, Title)
If Response = vbYes Then
Me!Brokerage = 0
Else
Exit Sub
End If
Else
If Not IsNull(Me!Premium) Then
Me!Brokerage = Me!Premium * .10
End If
End If
HTH,
Jana

Feb 21 '07 #4
On Feb 21, 4:13 pm, "Haas C" <haas...@yahoo.comwrote:
Hi all,

I was wondering if any of you guys can help me out with this:

I have two fields on a form: one field is Premium and the other is
Brokerage. Whatever amount is in the Premium field is multiplied by
10% in the Brokerage field. If I change the amount in the Premium
field, the Brokerage amount should change accordingly as well. I know
I can do this in a query with a simple calculation set up; however,
there are exceptions to the 10% rule. Therefore, I'll need the ability
to change the amount in the Brokerage field from time to time - with a
Query, that won't be possible. What is the easiest way to acomplish
what I want. I am a newbie so if you can provide me with step-by-step
instructions, it will be most appreciated.

Thanks!
Haas,

The answer depends on _when_ you'll be changing the Premium values or
rewriting the rules. Generically, I can think of 3 ways you might be
needing this...

If you are calculating at the time of Premium entry based on the
current rules, and storing that forever (like a receipt), then you
should apply the equations to set Brokerage using the "OnUpdate" or
"OnInsert" event of the Premium Field. You could do this with VBA if/
then statements, or you could do this with Macro conditions.

If you're looking to store the Premium values and create a table of
Brokerage values, but then change those Brokerage values when the rule
changes... then in that case, I would actually trigger an update query
using Where clauses or iif expressions.

Finally, if you just want to view Brokerage values on a report, then
I'd just use an iif statement with your rules in a text box (as
opposed to actually having a field called "Brokerage").

It might also help if you tell us the busienss rules you use in
addition to the 10% rule.

Jon

Feb 21 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve | last post by:
Does any anyone have a procedure for a query where a calculated field returns the previous record's value in another field. For example: A F ...
1
by: Emmanuel | last post by:
Hi, I have a webform with some input controls in it. Some of these controls have validation controls assigned. So far so good. I would like to...
3
by: skinnybloke | last post by:
Hi - I have the following VB function within MS Access which is called via a query. How do I modify this code so that it will only do the...
1
by: abprules | last post by:
Can somebody help me with this scenario? I want to update a date field when another field has a certain value entered. It is something like...
1
by: sillyr | last post by:
Hi I wanted to make a statement in a form to take a value from one field if the first field has no value. I have a form created from two tables. ...
14
by: mjvm | last post by:
HI, I have had a search for the answer to this question, but I can't transfer what I am reading to my database. I don't know enough about the...
3
by: BobbyD1120 | last post by:
I have created a inventory tracking database and I want to show/hide certain fields based on the device category. The deviceCategory field is a...
1
by: Totti | last post by:
Hello, I am new to MS Access (2007) and am trying to create a hyperlink in a table to Google maps without much luck. The URL I need to use in my...
4
by: nedryerson | last post by:
Hi, I'm trying to get a certain field to appear only when a value from another combobox field is selected. Specifically, when "Sample Rejected"...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.