Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2003
    Posts
    5

    Lightbulb Unanswered: calculated form value problem (stupid ?)

    Let me first state: I am pretty new to access, and I need some help.

    I have 1 table with 1 form.

    The form has a text box that calculates the following:
    =[MembershipFee]-([Discount]+[Scholarship])

    This calculated number is displayed on the form just fine, but HOW can I take this calculated value and put it into my "Sub-Fee" field in my table?


    If this doesn't make sense I can try to explain in detail more. Any help would be greatly appreciated.

    -Kevin

  2. #2
    Join Date
    Oct 2003
    Posts
    311

    Re: calculated form value problem (stupid ?)

    Originally posted by bokev
    Let me first state: I am pretty new to access, and I need some help.

    I have 1 table with 1 form.

    The form has a text box that calculates the following:
    =[MembershipFee]-([Discount]+[Scholarship])

    This calculated number is displayed on the form just fine, but HOW can I take this calculated value and put it into my "Sub-Fee" field in my table?


    If this doesn't make sense I can try to explain in detail more. Any help would be greatly appreciated.

    -Kevin
    Im not to great at it either but try something like this in a cmdBtn click event

    dim cn as new adodb.Connection
    set cn = currentproject.connection

    dim sql as string

    sql= "Update myTbl set myField = " & me.MyTxtBox.value & "Where primarryKey=what ever your key is "

    cn.execute SQL

    cn.close
    set cn to nothing


    Im sure that wont work but might get you on the way sorry couldnt do better

    M~

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    I have 1 table with 1 form.

    The form has a text box that calculates the following:
    =[MembershipFee]-([Discount]+[Scholarship])

    This calculated number is displayed on the form just fine, but HOW can I take this calculated value and put it into my "Sub-Fee" field in my table?


    If this doesn't make sense I can try to explain in detail more. Any help would be greatly appreciated.

    -Kevin

    If these three values [MembershipFee], [Discount] and [Scholarship] should be given in TextBoxes on your form, and if your form has your Table as a RecordSource then, make a fourth TextBox i.e txtResult then
    in the form_Current event write

    Private Sub Form_Current()
    if not isnull (txt_MembershipFee) and not isnull(txt_Scholarship) _
    and not isnull(txt_Discount) then
    ___________txtResult= txt_MembershipFee-(txt_Discount+txt_Scholarship)
    _____endif
    End Sub

  4. #4
    Join Date
    Oct 2003
    Posts
    5
    Ok Im getting there... The only problem I have now is:

    If I open the Form (add/edit my calculated fields) & Close the Form. The Table does not get updated until I open & close the Form AGAIN. Whats wrong in my code? I dont want to have to open & close the form after ever update.

    Maybe I have the code in the wrong place??

    Here is my code for the Form:
    =======================================

    Private Sub Form_Current()

    If Not IsNull(txt_MembershipFee) And Not IsNull(txt_Scholarship) _
    And Not IsNull(txt_Discount) Then
    txtResult = txt_MembershipFee - (txt_SDiscount + txt_Scholarship)
    End If
    [SubFee] = [txt_SubFee]

    If Not IsNull(txt_SubFee) And Not IsNull(Fall$) _
    And Not IsNull(Winter$) And Not IsNull(Spring$) And Not IsNull(Summer$) _
    Then
    MOwedResult = [txt_SubFee] - ([Fall$] + [Winter$] + [Spring$] + [Summer$])
    End If
    [MOwed] = [MOwedResult]

    End Sub

  5. #5
    Join Date
    Oct 2003
    Posts
    5
    UPDATE:

    This is exactly what happens:

    1. I create a new entry in (using the form)
    2. close the form
    3. open the form
    4. scroll to the same entry I just created
    5. close the form
    (NOW the table is updated with the updated SubFee value)

    The SubFee value doesn't get updated until I re-open the form to that entry and close the form.

    ANY HELP??

    here is the code again
    ==============================================
    Private Sub Form_Current()

    If Not IsNull(txt_MembershipFee) And Not IsNull(txt_Scholarship) _
    And Not IsNull(txt_Discount) Then
    txtResult = txt_MembershipFee - (txt_SDiscount + txt_Scholarship)
    End If
    [SubFee] = txtResult

    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •