Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Rory898 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    14

    Question Form Help

    I am looking for a piece of code or macro of some kind to decrease the value in a field each time the form is opened. i.e:

    The amount in stock is 400


    each time the form opens i want it to go down by 20

    therefore it will be 400 then 380 then 360 then 340 etc

    Thanks in advance for your help
    Last edited by Rory898; 01-28-2010 at 01:46 PM.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Is the field in the RecordSource of the form you are opening?

  3. #3
    Rory898 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    14
    Sorry what do you mean record source?

    It is linked to a stock table. Its not a calculated field or anything

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    On the Data tab of the property sheet for the form is the RecordSource property. Does this point to the table you want to modify?

  5. #5
    Rory898 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    14
    yea it is pointing to the table

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    You said each time the form opens. Is there only one record in the table?

  7. #7
    Rory898 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    14
    Theres 3 separate values in the table but i only want one of them to decrease by 20

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    You can use the OnLoad event to change the field but it will be pointing to the first record in the table. Is there only one record in the table?

  9. #9
    Rory898 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    14
    There are 6 records in the table

    Text Paintball gun Supplier Name
    Number Guns In Stock
    Text Overalls Supplier
    Number Overalls In Stock
    Text CO2 Gas supplier
    Number Amount in Stock <-- this is the value that i want to change

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    That appears to be a strangely designed table. Have you studied up on normalization yet? Are those 6 Rows in the Table or 6 Columns in one Row? Here's a starting link on normalization: http://support.microsoft.com/kb/283878

  11. #11
    Rory898 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    14
    yeaaa but the table isnt related to anything else. I just made it for this purpose of a form. I could remove the Text rows.

    so it would just be :

    Guns in Stock:
    Overalls in Stock:
    CO2 in stock:

    Would this make it simpler?

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Rory,
    The problem I'm having is you seem to have a table with one field (Column) that changes back and forth between a text field and a numerical field. You can not do this in Access unless the "Numerical" field is really a text field which is a waste of resources of Access. It sounds like you are running a PaintBall park.

  13. #13
    Rory898 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    14
    Yea it is a paintball system. Here is the table and form. I would be extremely grateful if you cud take a look at it.

  14. #14
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    That explains a lot Rory, thanks. Why do you have the Text fields in your table? I doubt you will forget what the next field will contain and besides it has a name as well that tells you what it contains.

  15. #15
    Rory898 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    14
    yeaaaa it was pretty unneccesary. So do you think i should remove all the text fields? and then how would i get the co2 field to decrease by 20 when it is opened?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

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