?
Solved

Update a Field based off a Percent

Posted on 2011-09-30
7
Medium Priority
?
297 Views
Last Modified: 2013-11-28
Experts,

I have this form with a field control source named [Percent]
I also have a field control source named [Amount]
I also have an unbound field with =[Percent]*DLookUp("[Amount]","tblLetterOfCredit","[LetterOfCreditID] = " & [Forms]![frmLetterOfCredit_Cont]![LetterOfCreditID])

I need the value of this amount in the unbound field (named PctAmount) to be updated to the other field [Amount].

I want to capture the calculated amount and put it in the field [Amount] so it will be in the table.

please see pic

untitled.JPG
0
Comment
Question by:pdvsa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
7 Comments
 
LVL 19

Expert Comment

by:Richard Daneke
ID: 36894985
I am still confused with your question.  Is the blank box supposed to end up as the calculated result?
And, is the original Amount and the new calculated amount both stored in the table?

one option:
Use a bound field instead of the unbound field.  Use the Expression builder to enter your formula in the AfterUpdate event on both the Percent and the Amount fields to calculate the NewAmount field as defined.
This will result in the new amount field being calculated whenever the percent or amount number changes and in being stored in the new field name of your table.
0
 

Author Comment

by:pdvsa
ID: 36895000
DoDahD:
<Is the blank box supposed to end up as the calculated result?
Yes
<And, is the original Amount and the new calculated amount both stored in the table?
I do have a field called [Amount] in the table.  I also have a field called [Percent]

Does that change anything?
0
 

Author Comment

by:pdvsa
ID: 36895013
What formula would I use?  
I tried something like

AfterUpdate:
me.Percent = Me.Amount

but it said that it cant assign a value to this field.  
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:pdvsa
ID: 36895015
I mean me.CalcAmount = me.Amount

0
 
LVL 40

Accepted Solution

by:
als315 earned 2000 total points
ID: 36895603
Be careful with names in your form. May be better to add 1(2,3 etc) to field Amount if your table have also such field. Check also left and right sides of equation.
If field in table (which should be updated) is Amount, give name of field in form -Amount1. Equation will be:
Me.Amount1 = Me.PctAmount
Try also:
Me.Amount1 = Cdbl(Me.PctAmount)
0
 

Author Comment

by:pdvsa
ID: 36897322
ok that helped out a lot.  

The Me.Amount1 = Me.PctAmount ==> was not the solution
       Me.Amount1 = Cdbl(Me.PctAmount)===> was the solution

I finally ended up with this:
(pay attention to the current event.  I am not completely sure if there is something blatently wrong with it but it seems to work.  I had to add the If statement and I am not a programmer for certain.

Option Compare Database

Private Sub CalcAmount_Change()

    Me.Amount1 = CDbl(Me.CalcAmount)
   
End Sub

Private Sub Form_Current()

    If Nz(Me.Amount1, 0) = 0 Then
        Me.Amount1 = Me.CalcAmount
     Else
     
    Me.Amount1 = CDbl(Me.CalcAmount)
   
    End If
   
End Sub

Private Sub txtPercent_AfterUpdate()

    Me.Amount1 = CDbl(Me.CalcAmount)
   
End Sub
0
 

Author Comment

by:pdvsa
ID: 36897329
Thhe  Current Event could possibly be simplified... if you see it please let me know.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question