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.

Share This Page