Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    subtracting a value (Access97)

    I have a form, DataForm, that I use display the data in an underlying form. The table is called data. There are 2 field in this table Work area and Jobs available. Jobs available is a number field. What I would like to do is when the user of the form selects a work area they click a button that will subtract 1 from the total of the jobs available field. An ideas? Thanks..

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: subtracting a value (Access97)

    Note: I'm using a foreign language version of Access, so my wording may be slightly off.

    Put a command button on the form. Make sure it is selected.
    In the Properties window, select the Other tab.
    In the box labeled Name, enter a name, for instance cmdSubtract.
    Next, select the Events tab.
    Click in the box labeled OnClick. A dropdown arrow and a small button with three dots ... should appear on the right hand side.
    Click on the small button and select Program code builder.
    You're taken to a code window, with the skeleton of the OnClick procedure ready for you to use:

    Private Sub cmdSubtract_Click()

    End Sub

    In the empty line between Private Sub ... and End Sub, hit the Tab key to indent and then type

    [Jobs available] = [Jobs available] - 1

    The brackets around the field name are necessary because there is a space in the name.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: subtracting a value (Access97)

    Thanks that does work on the form but how can I have it subtract 1 from the value of the underlying table? This only subtracts the value when the form is open...

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: subtracting a value (Access97)

    It is subtracting the value from the underlying table, or at least it is if [jobsavailable] on your form is bound to the table field of that name. If that isn't working for you, I suspect there's more to your question that has been exposed so far.
    Charlotte

Posting Permissions

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