Results 1 to 4 of 4
  1. #1
    zx3 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Aug 2011
    Posts
    47

    Exclamation Error message after deleting query by vba

    Hi all,



    I am working on this project using a form to search for a member, in form 1 when putting in memno (table1) in the box next to the search button and click search, the respective member's name will appear on the listbox below and the details of that member will be listed in the detail section of the form. When user click the member's name in the listbox, the subform will show its score and allow user to put notes which in turn update Table:sports.

    So far everything is working as expected, but when user try to close the form, a message will pop up because during the update of the subform by vba a temporary query is deleted, and access does not seem to notice that, here's the screen shot of that message.Click image for larger version. 

Name:	errorMsg.jpg 
Views:	10 
Size:	16.2 KB 
ID:	35973

    Please note that the message does not allow user to close the form, to close the form i go to the vba of that form, comment out a line and save it, come back to close the form again, the message show again then it will close.

    Please note also if you enter a 4 in the search box, which is one of the values in memno column of table1, the error message will be exactly the same as shown above.

    I tried so many things to get rid of that but i just can't, please help.

    And here is the file myDb.accdb

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    See if this works for you. You don't need a different named query for each member. Delete the query and recreate as necessary for each member.
    I added OPTION EXPLICIT to modules and dimmed all orphan variables. Added DAO. to file related objects.
    Added a form_open event to clear out some control values.
    Commented out some unnecessary code.

  3. #3
    zx3 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Aug 2011
    Posts
    47
    Quote Originally Posted by davegri View Post
    See if this works for you. You don't need a different named query for each member. Delete the query and recreate as necessary for each member.
    I added OPTION EXPLICIT to modules and dimmed all orphan variables. Added DAO. to file related objects.
    Added a form_open event to clear out some control values.
    Commented out some unnecessary code.
    Thanks davegri for your quick reply, it works great!!!

    And i improved it a bit to get rid of leftover tmpqy query and the layout saving message prompted at the closing of the form.

    Here's the improved version based on davegri's suggestions/improvements zx3-davegri-v02.zip

    It is really great that i can get to this point so quick and easy, thanks again.

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    Glad to help. Good luck with the rest of your project!

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

Similar Threads

  1. Replies: 3
    Last Post: 10-21-2018, 08:24 AM
  2. Replies: 9
    Last Post: 02-10-2017, 05:26 AM
  3. Replies: 7
    Last Post: 03-17-2016, 05:53 PM
  4. Replies: 14
    Last Post: 03-31-2015, 05:20 PM
  5. Replies: 11
    Last Post: 12-14-2010, 01:25 PM

Tags for this Thread

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