Results 1 to 3 of 3
  1. #1
    allenom is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2011
    Posts
    4

    Add a value to the same field for all items on a subform at once

    Hello-
    I am using Access 2000 to build a database of car parts, and the cars they are currently installed on. I can assign each item on the "parts" table to a particular car listed on the "cars" table (or to its current location if it is not on a car). I can look at the cars individually, and have a subform that shows the parts currently assigned to that car in a list.


    That much is great, and is exactly how I want it.
    Here is my question:
    One of the fields in the "parts" table is "hours." Every time I use a particular car, I would like to increment each of the parts assigned to that car with the hours they were used. Ideally, I would have a form called "Use Vehicle" or similar, and in it I could select the particular car from a dropdown, and a subform would show the particular parts assigned to it. Then, I want to either: a) push a button with a particular time increment (like 0.25 hours) OR b) just enter a value in a box, which would then ADD that number to the "hours" field for every part in the subform.
    Is this possible?
    Thanks in advance,
    Al
    Last edited by allenom; 09-29-2011 at 06:45 PM. Reason: typo

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If I understand right, you want to increment the value in a field named "hours".

    So you would have a combo box/list box (cboVehicle) to select the vehicle , a text box (txtIncHours) to enter the amount of hours and a button (btnAddHours) to execute the code.

    Select the vehicle, enter to hours, click the button to execute the code.

    The following is air code. But it is a start.....

    Code:
    Private Sub btnAddHours_Click()
       Dim sSQL As String
    
       'you might need more criteria to select only the
       ' vehicle parts for teh specified vehicle if you use the table.
       ' Or use the query for the subform to get the parts.
       sSQL = "UPDATE TableName SET TableName.Hours = [Hours]+ " & Me.txtIncHours
       sSQL = sSQL & " WHERE TableName.Vehicle_ID = " & Me.cboVehicle & ";"
    
       CurrentDb.Execute sSQL, dbFailOnError
    
       'might have to requery the subform
    End Sub

  3. #3
    allenom is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2011
    Posts
    4

    Thanks-

    Thanks, I will give that a try!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 07-29-2011, 09:30 AM
  2. Replies: 7
    Last Post: 07-15-2011, 01:58 PM
  3. Replies: 1
    Last Post: 02-03-2011, 11:19 AM
  4. Replies: 2
    Last Post: 09-22-2010, 09:26 AM
  5. Lookup column relating items in same field
    By rmroberts76 in forum Access
    Replies: 8
    Last Post: 06-05-2010, 07:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums