Page 1 of 3 123 LastLast
Results 1 to 15 of 44
  1. #1
    Amyfb is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    64

    Only One Button code works on this form - troubleshoot help requested

    I've been over this numerous times, finding and fixing typos ( - instead of = as ex) . At this point, I'm unable to find any thing else that is causing the code for this form to fail.

    The Close button works. so does setting the focus on the last name field. otherwise it's dead in the water.

    The code comes from a book i'm studying. I'm accomplished the earlier examples of sample code for different parts of this package and now it's time to put all those little bits together.



    No doubt there are eagle eyes in this group who will see the problem before I've come back with a fresh cup of coffee.

    Thanks in advance for taking a look and tossing ideas over to me. I've got 22 more chapters to go before I can get to work on my real project!


    cheerios
    amy
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Did you run Debug Compile?
    Right off I get error "Can't assign to read-only property."

    Why is there no table? How would you expect procedures to add/update/delete data to work when there is none?

    I have never used Class Modules.

    I don't use macros, only VBA (only exception is AutoExec macro).

    Also never used UNBOUND form for data manipulation.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,792
    I took a look. You're using embedded macros. That's what the book is suggesting you do? I suppose that's one way to begin learning but I haven't used any macro save for AutoExec in so long that I no longer know how to create or edit them beyond what an AutoExec usually does. Most of us only use code as macros are too limiting. You may not be too eager to learn code, but consider that eventually you will likely migrate to code and all the time you spend learning macros might be a waste.

    You can turn on single step option, open form again and click, then you'll step through and can review the conditions. I did that and added a couple of parameters (form name and object type) to no avail. Hopefully we have a macro savvy person lurking here. Seems to me that the error condition (<> 0) is false but I don't know why.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    You are using macroes, I do not use those, except for batch operations.
    I'd start using VBA if I was you.

    You form is also unbound, most use bound forms I believe, something you have to get used to in Access.?
    All this Add/Save not particularly needed, if doing it the Access way. You can still roll your own with Add and Save, but more work I believe.

    I just got used to bound forms for most of my forms.

    If you use unbound forms, you have to insert the data yourself, before you can go to a new record, which in reality is just clearing the current form each time?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Most/many developers do not use macros.

    When showing some sample code that isn't "working", best to provide some description of what you are trying to accomplish. And what you expected as a result.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,792
    You form is also unbound
    That is the key.
    I altered the first setting to "Fail" and the error that I couldn't seem to raise is 2046 (GoToRecord not being available).
    Makes sense that you can't go to a record when there isn't any. The error response setting was basically ignoring the error, much like "Resume Next" would in vba, I guess.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Amyfb is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    64
    I don't understand the reference to macros - i've typed out every scrap of code in the modules using VBA code as written out in the book i have.

    i did not use the macro builder, i used the code builder.

    as for not having a table - now that is an interesting point that I can't argue with.

    I'm ready to toss this book in the trash - it's been a headache from page one. It's as if every other example is missing some little bit.
    Does anyone have a recommendation for a solid workbook?

    i'm also working my way through steve bishops youtube classes, but I like paper for reference also.

    thanks
    Amy

  8. #8
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,792
    i did not use the macro builder, i used the code builder.
    Are you absolutely sure? Look at the OnClick event property setting for your button. It definitely shows [embedded macro].

    Click image for larger version. 

Name:	1embedded.jpg 
Views:	35 
Size:	25.6 KB 
ID:	46083
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    ALL your buttons are using Embedded Macro ?
    I can see you do have VBA code for various events, but you still need to tell Access which method you are using.?

    There is a setting to always use VBA, someone else here will likely know it. I will have to search for it.

    Found it.
    Options/Object Designers/Forms
    Always use event procedures
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    i did not use the macro builder, i used the code builder.
    But all the "Click" events are set to [Embedded Macro] rather than [Event Procedure] which would need to be the case if you want the code to fire.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,792
    Options>Object Designers>Form/Report design view>always use event procedures (checkbox).
    I too now see that there is code.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Christ!, you are using Collections.

    Talk about jumping in at the deep end.

    I have never used a Collection

    Not saying it's wrong, but I'd learn to trot before trying to gallop.

    That book seems somewhat advanced to me.
    I have a Dummies Guide to Access 2007, given to me by my last bosses.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  13. #13
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Your book is instructing you to use custom classes. I would estimate that over 98% of Access developers do not ever code custom class modules. It's a very specialized niche, and in my opinion is never required, as the desired result can be accomplished via normal VBA code. Your book seems heavy on theory, with not enough emphasis on practical common actual coding solutions.
    I don't have an alternate suggestion for a book, but perhaps in the review or "Who this book is for" look for phrases like "practical", "everyday", "common", "beginner", "intermediate". AVOID "advanced" and such.

  14. #14
    Amyfb is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    64
    Quote Originally Posted by Welshgasman View Post
    Christ!, you are using Collections.

    Talk about jumping in at the deep end.

    I have never used a Collection

    Not saying it's wrong, but I'd learn to trot before trying to gallop.

    That book seems somewhat advanced to me.
    I have a Dummies Guide to Access 2007, given to me by my last bosses.
    Hah, that's me ! running before i can walk.

    I did start at lesson one, and each one has been building on the previous one, so, even running it seemed like i could get through ok.

    but, i take the point about it being an advanced topic.

    i'll dial back and slow down a little......hard as it is for me who wants it all now.

    thanks

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914

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

Similar Threads

  1. Code only works after form is loaded 2nd time
    By joecamel9166 in forum Forms
    Replies: 1
    Last Post: 05-05-2016, 02:12 PM
  2. Replies: 2
    Last Post: 04-09-2015, 03:39 PM
  3. Replies: 4
    Last Post: 11-26-2013, 10:47 AM
  4. Replies: 10
    Last Post: 02-12-2013, 05:04 PM
  5. Replies: 6
    Last Post: 09-02-2012, 04:30 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