Results 1 to 13 of 13
  1. #1
    heinensk23 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    13

    Error while trying to use a combobox as a filter

    I am getting an error with the below code.
    Error is attached.


    Private Sub cmbo_Menu_Group_AfterUpdate()


    Dim myMenugroup As String
    myMenugroup = "Select * from tbl_BRASS_Menu_Item_Setup where [MENU_GROUP_TARGET] = & Me.cmbo_Menu_Group "


    Me.subfrm_BRASS_ITEM_SETUP_subform.Form.RecordSour ce = myMenugroup
    Me.subfrm_BRASS_ITEM_SETUP_subform.Form.Requery


    End Sub
    Attached Thumbnails Attached Thumbnails 2021-01-15_20-55-13.png  

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    if menu_group is a string use this:
    myMenugroup = "Select * from tbl_BRASS_Menu_Item_Setup where [MENU_GROUP_TARGET] = '" & Me.cmbo_Menu_Group & "'"


    If Menu_Group is numeric then use this:
    myMenugroup = "Select * from tbl_BRASS_Menu_Item_Setup where [MENU_GROUP_TARGET] =" & Me.cmbo_Menu_Group
    Last edited by davegri; 01-15-2021 at 08:18 PM. Reason: format

  3. #3
    heinensk23 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    13
    MENU_GROUP_TARGET in tbl_BRASS_Menu_Item_Setup is a short text so I used the first option and am now getting another error.

    Click image for larger version. 

Name:	2021-01-15_21-27-27.png 
Views:	18 
Size:	5.7 KB 
ID:	43919

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    Quote Originally Posted by heinensk23 View Post
    MENU_GROUP_TARGET in tbl_BRASS_Menu_Item_Setup is a short text so I used the first option and am now getting another error.

    Click image for larger version. 

Name:	2021-01-15_21-27-27.png 
Views:	18 
Size:	5.7 KB 
ID:	43919
    Maybe be best if you can post the db here for analysis.

  5. #5
    heinensk23 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    13
    Unfortunately it's too big to attach. I tried pulling out just the parts I am having problems with and it is still too large.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    you have
    & Me.cmbo_Menu_Group & " '' " (an extra single quote or a double between doubles; can't tell which).

    use
    & Me.cmbo_Menu_Group & " ' " (remove spaces I added for clarity).


    You probably didn't compact and then zip a cop of your db, which is why it's too large?

    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    heinensk23 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    13
    I don't have an option to zip the database.

  8. #8
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    Quote Originally Posted by heinensk23 View Post
    I don't have an option to zip the database.
    It's built into File Explorer:

    Click image for larger version. 

Name:	zip1.png 
Views:	16 
Size:	46.9 KB 
ID:	43921

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    has been built into windows versions for quite some time.
    https://www.wikihow.com/Zip-a-File-in-Windows-XP
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    heinensk23 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    13
    Thanks
    I have attached
    Attached Files Attached Files

  11. #11
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    Table is misnamed. Delete the red.
    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub cmbo_Menu_Group_AfterUpdate()
    
    
    Dim myMenugroup As String
    myMenugroup = "Select * from tbl_BRASS_Menu_Item_Setup where [MENU_GROUP_TARGET] = '" & Me.cmbo_Menu_Group & "'"
    Me.subfrm_BRASS_ITEM_SETUP.Form.RecordSource = myMenugroup
    Me.subfrm_BRASS_ITEM_SETUP.Form.Requery
    
    
    End Sub
    Edit: You also don't need the requery. The form had but little choice to requery itself when its recordsource was changed.
    Last edited by davegri; 01-15-2021 at 11:35 PM. Reason: addl

  12. #12
    heinensk23 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    13
    Thank you!
    It's working now.

  13. #13
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    Glad to help. It's easy to misname things when the names are long and involved. Good luck with the project!

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

Similar Threads

  1. Replies: 4
    Last Post: 01-14-2019, 05:03 AM
  2. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  3. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 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