Results 1 to 7 of 7
  1. #1
    pshoestir is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    11

    Where to start?


    This is my first post so please excuse any lack of etiquette or misuse of the forum. I am extremely new to VBA coding and have been working my way through some books and creating the projects shown. My most recent project is causing me a lot of frustration. I have written the code almost verbatim and have 98% of the items functioning properly. However, there is one piece of code that is working as it should and I can't for the life of me figure out where the problem is. Specifically, I have a running total on a form that was created, with a button that is supposed to clear out the field when clicked. The book that I have been working out of was written for Access 2003 so, I am thinking that might be where some of the problems are coming from. At any rate, I am attaching the file and if anyone has a few moments to look at the code for the Running Total Field Clear button and tell me where I need to make some changes, I will be very appreciative. Most likely to the trained eye this won't take more than a moment but, for this rookie, I have been looking at it for days and still coming up empty. Most importantly, I would like to understand the process in which this problem is identified so I can use it in future projects. Thanks in advance!

    Fruit Stand VBA Project.accdb

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    ?? Not sure what you're database is trying to show??
    No tables???
    Just a form??
    Please describe what you are trying to do and relate same to your database.

  3. #3
    pshoestir is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    11
    It is not supposed to be a functional database. It was just a project that I did straight out of a begginers VBA book. Basically the form acts as a quasi register for a fictitious fruit stand. You input how many of each fruit the customers wants and it calculates the subtotal, tax and, total. In addition there is a running total that adds all of the sales throught the fictitious sales day. The "clear running total" command is not working correctly and I cannot figure out why.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Fictitious or not there is no Rate/Sales etc. Where do you get Cost/Sales??

    Data is stored in tables. Forms are a means of representing the data to users/getting data from users.

    There is no click event on your reset Running Totals button.

    If you want a tutorial on database design, tables and relationships, try any on this page

  5. #5
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Wow! If only everyone's issue was this simple! Open your form in design view, make sure you can see the Events tab of the property sheet. Click on the offending reset button and look at the events that are defined for this object. What I see is - none. Unless something happened to my version when I opened it, it looks like you wrote (or pasted) this code into the vb editor without choosing an event from the property sheet. The result is there is a disconnect between your code and the object. When I clicked on the On Click event and pasted your code into it (and commented out the original) it works fine. So, always create an event by choosing one from the event tab of the property sheet, regardless of how you get the code into it.

  6. #6
    pshoestir is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    11
    Thanks for the response Micron. I must have forgotten to set it back when I was problem shooting. Unfortunately, that was not what the issue was. However, I was able to figure out what the problem was. A dang typo. I had the object name plural (cmdResetRunningTotals) but singular (cmdResetRunningTotal) in my code. I want to thank both you and Orange for taking time to help and I look forward to using this site more as I continue my VBA journey. Cheers!
    Attached Files Attached Files

  7. #7
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Well, I won't argue the point, but doing what I said fixed the problem. The reason there was a disconnect is that the code you had did not belong to the control because of the typo in the procedure name, or you changed the name of the control on the form. Probably the former. If it didn't happen from pasting or typing, how else would it?

    BTW, why have a button to clear one set of controls, then another to do only the running total? Why not just clear them all?
    e.g.
    Code:
    Private Sub cmdResetFields_Click()
        'reset application fields
    With Me
        .txtApples.Value = 0
        .txtBananas.Value = 0
        .txtOranges.Value = 0
        .lblSubTotal = "$0.00"
        .lblTax = "$0.00"
        .lblTotal = "$0.00"
        .lblRunningTotal = "$0.00"
    End With
    dRunningTotal = 0
    End Sub
    You might want to consider using the afterupate event on a fruit control to automatically calculate the total. I have noticed other things you might do, but I don't want you to think I am picking apart your project, so one last suggestion. It's customary to either set focus to a command button (especially if there is a close or exit button) so you can set control values as you are, or just rely on the tab order of controls. You'd set the tab order of the exit button to 0. That way, you don't have to code to move focus off of a control so that you can manipulate it. Good luck with your projects!

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

Similar Threads

  1. Not sure where to start with this one....
    By datahead in forum Access
    Replies: 1
    Last Post: 05-11-2015, 03:20 PM
  2. Where to start
    By Adsso in forum Access
    Replies: 1
    Last Post: 02-15-2012, 04:25 PM
  3. How to start?
    By bergjes in forum Queries
    Replies: 8
    Last Post: 12-28-2011, 11:52 AM
  4. VBA Won't Start
    By Randy in forum Access
    Replies: 3
    Last Post: 11-27-2011, 12:27 PM
  5. Where to start?
    By FullyFamous in forum Database Design
    Replies: 7
    Last Post: 12-20-2010, 03:27 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