Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Join Date
    Mar 2008
    Posts
    18

    Unanswered: Simple Access VB question

    Private Sub Roof_Costs_AfterUpdate()
    SF.DUMMY = SF.Roof_Costs * 2
    End Sub

    i want the Field DUMMY of a table to get field Roof_Costs (of same table) times 2.

    but i don't know the nomanclature for that code..

    is it TABLE.FIELD = or what do I type there to make it work
    Right now when I use the form it gives me an Error and VB points to that line in the code.

    i'm trying to do this basically, from website..
    -----------
    To achieve this, use the After Update event of the controls on your form to automatically calculate the fee:

    Set the After Update property of the Quantity text box to [Event Procedure].
    Click the Build button (...) beside this. Access opens the Code window.
    Enter this line between the Private Sub... and End Sub lines:

    Private Sub Quantity_AfterUpdate()
    Me.Fee = Round(Me.Quantity * Me.UnitPrice * 0.1, 2)
    End Sub
    -----------

    THANKS

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    So use ME, not SF. EG:

    Me.Dummy = Me.Roof_Costs * 2
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Mar 2008
    Posts
    18
    I Tried Me.Dummy = Me.Roof_Costs * 2
    and although it gives me no errors,
    I goto the record and find no value in the field 'Dummy' after exiting the Roof_Costs field on the entry form.

    the Roof_Costs value is there though that I entered...
    i must be missing somethin
    Last edited by spacechimp; 05-01-08 at 01:05.

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Ok, so with no errors, you shouldn't change it until you find out why you aren't getting the results you expect.

    Is the Dummy control on your form bound to the right field?

    Set a breakpoint to the line and run it again. When you enter break mode you'll be able to point to Roof_Costs and see whether this value is as expected. You can also do things like select the text Me.Roof_Costs * 2 and then press SHIFT-F9 to see if the calculation is working.

    You should find out what is going on by doing these things.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Sep 2007
    Location
    Global Village
    Posts
    185
    Check out the name of after update sub which you wrote the code into is exactly the name of your dummy text box, it seems to me it doesn't execute the sub as the name is not the same name of your text box.

  6. #6
    Join Date
    Mar 2008
    Posts
    18
    i dragged dummy right from the existing fields..so i know it's bound to the table.

    i will try all the stuff posted and see what i come up with

  7. #7
    Join Date
    Mar 2008
    Posts
    18
    Quote Originally Posted by Aran1
    Check out the name of after update sub which you wrote the code into is exactly the name of your dummy text box, it seems to me it doesn't execute the sub as the name is not the same name of your text box.
    i'm trying to put a value into Dummy as soon as Roof Costs is updated.

    not workin great so far but..

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what is dummy being used for
    is it an existing column in the db?

    Id place the code in the before update event not after update
    I'd make sure there is a control called dummy on the form
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Mar 2008
    Posts
    18
    dummy is just a variable I was using to figure this thing out.
    It's a column in the table that the form points to.

    I goto the table and see a value for roof costs but nothing for Dummy.
    I was just going by what this guy wrote at the bottom but that's not working all that well
    http://allenbrowne.com/casu-14.html

  10. #10
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    ^ Well the process of making one field get populated by the changing of another is a pretty standard practice. You should get it figured out How did you go with the breakpoint?

    Quote Originally Posted by healdem
    Id place the code in the before update event not after update
    If you're talking about the form's event procedures, then I'd agree. I was referring to the After Update for the control (Roof Costs).
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  11. #11
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    how about
    [fldDummy] = [fldCost]*2

    That should work. of course, change fldDummy to whatever the field name is in your table. same with fldCost

  12. #12
    Join Date
    Mar 2008
    Posts
    18
    Quote Originally Posted by jmahaffie
    how about
    [fldDummy] = [fldCost]*2

    That should work. of course, change fldDummy to whatever the field name is in your table. same with fldCost
    Dummy is the field name in my table..
    and Roof Costs is the other field name from table

  13. #13
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    Did you try it?
    Code:
    [Dummy]=[Roof Costs]*2

  14. #14
    Join Date
    Mar 2008
    Posts
    18
    Here is an attached snap of the debug screen..
    i only know a little about VB

    i got a value in roof costs but still NULL in Dummy..
    Attached Thumbnails Attached Thumbnails ACCESS snap.jpg  

  15. #15
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    try putting inm exactly what jmahafie has suggested
    what youve got there isn't the same

    place a msgbox after that
    eg

    msgbox ("Roof Costs:" & [Roof Costs] & vbcrlf & "Dummy:" & [Dummy])


    that will tell you explicitly if the new value has been assigned
    if it has then there is a snafu somewhere else
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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