how to write vb code in access 2007

Discussion in 'Microsoft Access VBA Modules' started by tjbvo, Dec 15, 2009.

  1. tjbvo

    tjbvo Guest

    Version: MSAccess 2007

    I have 3 fields in my database that contain currency.
    Field 1: PrincipleAmount
    Field 2: AmountPaid
    Field 3: AmountDue

    I have added a Command Button (cmdCalc) to the form.
    I need to write code that Subtracts Field2 from Field1 and returns the
    Balance in Field 3.

    I have no idea on how to gain access to and how to write code in MSAccess
    2007.
    I can do this in VB6.

    Thanking You in Anticipation
    Julian
     
    tjbvo, Dec 15, 2009
    #1
    1. Advertisements

  2. tjbvo

    xps35 Guest

    On 15 dec, 13:29, tjbvo <> wrote:
    > Version: MSAccess 2007
    >
    > I have 3 fields in my database that contain currency.
    > Field 1: PrincipleAmount
    > Field 2: AmountPaid
    > Field 3: AmountDue
    >
    > I have added a Command Button (cmdCalc) to the form.
    > I need to write code that Subtracts Field2 from Field1 and returns the
    > Balance in Field 3.
    >
    > I have no idea on how to gain access to and how to write code in MSAccess
    > 2007.
    > I can do this in VB6.
    >
    > Thanking You in Anticipation
    > Julian


    You do not need Field 3 in your database. Fields like these only cause
    corrupt data (in case you forget to push the button).
    If you want to show the amount dua in e.g. a query just make an
    calculeted field in the query: PrincipleAmount - AmountPaid.

    Groeten,

    Peter
    http://access.xps350.com
     
    xps35, Dec 15, 2009
    #2
    1. Advertisements

  3. tjbvo

    Mr. B Guest

    You don't need the command button or any VBA code to do what you want.

    Select the text box where you want the result of the calculation and display
    the Properties Dialog box. Locate the Data Tab and then locate the "Control
    Source" property. In that row type:

    = [NameOfFirstTextBox] - [NameOfSecondTextBox]

    Just be sure to supply the actual names of the controls that will supply the
    values to be calculated.

    -----
    HTH
    Mr. B
    http://www.askdoctoraccess.com/
    Doctor Access Downloads Page:
    http://www.askdoctoraccess.com/DownloadPage.htm


    "tjbvo" wrote:

    > Version: MSAccess 2007
    >
    > I have 3 fields in my database that contain currency.
    > Field 1: PrincipleAmount
    > Field 2: AmountPaid
    > Field 3: AmountDue
    >
    > I have added a Command Button (cmdCalc) to the form.
    > I need to write code that Subtracts Field2 from Field1 and returns the
    > Balance in Field 3.
    >
    > I have no idea on how to gain access to and how to write code in MSAccess
    > 2007.
    > I can do this in VB6.
    >
    > Thanking You in Anticipation
    > Julian
     
    Mr. B, Dec 15, 2009
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul

    how to write VBA code retrieve data from Excel to Access

    Paul, Sep 16, 2003, in forum: Microsoft Access VBA Modules
    Replies:
    3
    Views:
    650
  2. Chris A.

    Write Conflict in Code

    Chris A., Oct 8, 2003, in forum: Microsoft Access VBA Modules
    Replies:
    1
    Views:
    231
    Emilia Maxim
    Oct 14, 2003
  3. Jean

    DAO code to write records

    Jean, Nov 22, 2003, in forum: Microsoft Access VBA Modules
    Replies:
    3
    Views:
    253
    Tim Ferguson
    Nov 23, 2003
  4. Guest
    Replies:
    1
    Views:
    183
    Douglas J Steele
    Jan 30, 2006
  5. scolino

    code worked in Access 2003, not Access 2007

    scolino, Feb 23, 2009, in forum: Microsoft Access VBA Modules
    Replies:
    1
    Views:
    223
    Tom van Stiphout
    Feb 23, 2009
Loading...

Share This Page