Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 39
  1. #16
    joe.ise is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Location
    Ferrum, VA
    Posts
    22

    Code it is then. I took a C++ class many years ago and barely passed, so I am not a code writer but I will try my best. What I have done is copied the last set of code we used to calculate current inventory and pasted it into "Module2" in the attached database. Then I wrote some comments, all begin with the double asterisks **. If you have time to look at that and give me some feedback that would be great.
    Thanks RuralGuy
    Attached Files Attached Files

  2. #17
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm going to suggest you start by looking at your module and then go to Debug>Compile and fix all of the problems first. All modules should begin with:
    Option Compare Database
    Option Explicit
    ...to eliminate typos.

  3. #18
    joe.ise is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Location
    Ferrum, VA
    Posts
    22
    So I added "Option Explicit" to Module2, clicked Debug, Compile and it opened the Form_tblStockTake (Code) and threw the error shown in attached. So I added "Option Explicit" to Form_tblStockTake (Code) and it threw the same error.
    Attached Files Attached Files

  4. #19
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    That's right. That code does not belong in the form and you can't put a Function inside of a Sub.

  5. #20
    joe.ise is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Location
    Ferrum, VA
    Posts
    22
    I am not exactly sure what a Sub is but I removed the line of code that I think was the Sub, Debugged again and got the attached error.
    Attached Files Attached Files

  6. #21
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You have still not renamed the Function in the 2nd module and the OnHand function is already in the 1st module.

  7. #22
    joe.ise is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Location
    Ferrum, VA
    Posts
    22
    Is the Form_CurrentInventory not supposed to have a Sub as well ? I also added "Option Explicit". Still getting same error.
    Attached Files Attached Files

  8. #23
    joe.ise is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Location
    Ferrum, VA
    Posts
    22
    Sorry, just saw your 8:26 am reply, working on it

  9. #24
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    None of your errors are being caused by the Option Explicit statement. Option Explicit simply insists you Dim any variable before you use it.

  10. #25
    joe.ise is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Location
    Ferrum, VA
    Posts
    22
    OK
    I renamed the function in Module2 to be OnHandTwo and anywhere else in the code where I saw OnHand I changed it to OnHandTwo. I clicked Debug and the Compile option was shaded out / not available. I assume that means it is good, not sure.
    Attached Files Attached Files

  11. #26
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Edit a module, Add a space somewhere and take it out and the Compile should now be available. If it completes without an error, you have made all of the corrections for now. Post a new copy of your zipped db for us.

  12. #27
    joe.ise is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Location
    Ferrum, VA
    Posts
    22
    I edited the module by adding a space and removing and compile became available as you said. It ran with no errors. I also added vOrderUpToQuantity in the top area of the function, Debugged and rand with no errors. I assume now I basically have a copy of the Allen Browne example in Module2 renamed OnHandTwo. So I think it should do the same thing as OnHand, so now I need to add codes somewhere at the bottom that says:
    If CurrentInventory is less than ReOrderQuantity tell the user to order OrderUpToQuantity minus CurrentInventory.
    New copy of zipped db attached as requested.
    Attached Files Attached Files

  13. #28
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I believe you've got it.

  14. #29
    joe.ise is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Location
    Ferrum, VA
    Posts
    22
    I took a stab at it. My code is in screenshot 12, my error after compiling is in screenshot 13. Any advice ? Thanks
    Attached Files Attached Files

  15. #30
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Every If requires an End If.

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Sample database for a beginner
    By amphinomos in forum Sample Databases
    Replies: 4
    Last Post: 07-13-2013, 03:51 PM
  2. Beginner thread, 1 problem when using forms
    By c.yyang in forum Access
    Replies: 8
    Last Post: 06-22-2013, 11:26 PM
  3. Problem with tables (beginner)
    By alouest in forum Access
    Replies: 5
    Last Post: 04-05-2012, 12:08 PM
  4. Inventory Control DB (Beginner)
    By Clayton252 in forum Database Design
    Replies: 1
    Last Post: 10-06-2010, 06:41 PM
  5. Absolute beginner qu - transferring a database
    By kirstywing in forum Access
    Replies: 2
    Last Post: 09-07-2010, 02:12 AM

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