Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Join Date
    Jun 2023
    Location
    Jacksonville, FL
    Posts
    26

    Search (Filter) button on main form to also get proper records on subform

    I have a music database that tracks titles, songs, composers and performers. I would like to set up a search button for the TitleNumber field on the main form and have the subform with two nested subforms updated when the filter is applied to the main form. The record source for frmTitles is tblTitles. The subform subfrmSongs is related to frmTitles. On the subform are two nested subforms, subfrmComposer and subfrmPerformer.



    Click image for larger version. 

Name:	MMRelationships.jpg 
Views:	29 
Size:	47.7 KB 
ID:	50424


    On the main form I have created btnSearchCatNumber. It asks the user to input a catalog number. When the button is click the proper information is displayed on the main form but not the subfrmSongs and the nested subforms. How do I accomplish this?

    Code:
    Private Sub btnSearchCatNumber_Click()
    
          Dim strCatNumber As String
         
          strCatNumber = InputBox("Enter Catalog Number", "Catalog Number", TitleNumber)
         
          If strCatNumber = " " Then
               Exit Sub
          End If
         
          Me.Filter = "TitleNumber = """ & strCatNumber & """"
          Me.FilterOn = True
         
    End Sub
    Last edited by PlayerPianoMan; 06-28-2023 at 09:56 PM. Reason: readability

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Suggest input to an unbound textbox or better, a combobox, instead of InputBox. InputBox is harder to validate input and prone to user mistyping. With combobox can use TitleID for filter.

    I don't quite understand table relationships. What data entity is tblTitles for? Title is not a song?
    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
    Join Date
    Jun 2023
    Location
    Jacksonville, FL
    Posts
    26
    The table tblTitles holds information about each title like media type (CD, LP, 45, etc.), Catalog Number or purchase source and so on. Each Title can have many songs (SongTitle) so the TitleID (autonumber,PK) is related to tblSongs (MediaTitle, FK). Each song can have more than one performer and more than one composer hence the many to many relationship for both using junction tables. I would rather use the input box. I will be the only one using the database so the input values will be valid.

    When I click the button the information for frmTitles shows the correct information but neither the subfrmSongs or the nested subforms are updated. I get a box asking for a parameter ComposerID Ok or Cancel. If I hit the esc key 10 times (the number of songs for the filtered item) the subforms then update. If I don't press the esc key the database crashes.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Are Master/Child Links properties set on subform container controls?

    Could provide db for analysis. Follow instructions at bottom of my post.
    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.

  5. #5
    Join Date
    Jun 2023
    Location
    Jacksonville, FL
    Posts
    26

    Database File

    MMTestDb.zip

    Attached is a stripped copy of my database. None of the image files will display and you may get an error.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I tested with search for "HMK 026CD" on form frmTitles. It works - all forms are updated. No additional popup prompt. What data should I use to replicate issue?

    Why do some records not have TitleNumber?
    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.

  7. #7
    Join Date
    Jun 2023
    Location
    Jacksonville, FL
    Posts
    26
    Some titles will not have a TitleNumber aka Catalog Number because they are a digital file that was downloaded.

    I tried the same search for "HMK 026CD" and I was prompted for a parameter and the songs, composer, group/performers in the subform were not correct. I circled the prompt and the items on the subform.

    This would seem to indicate that it may be the different versions of Access. I am using the most recent Microsoft 365 version of Access 64 bit.



    Click image for larger version. 

Name:	frnTitlesError.jpg 
Views:	19 
Size:	192.0 KB 
ID:	50429

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    As shown by my profile, I use Access 2010 32-bit.

    There is little or no advantage gained by use of 64-bit for most.
    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.

  9. #9
    Join Date
    Jun 2023
    Location
    Jacksonville, FL
    Posts
    26
    Are you saying that this is the problem? I had to go to 64 bit because most of the people that I write code for has switched to 64 bit because their work required it so I had to since you can only have one installation either 32 bit or 64 bit. When you ran your search what was the first song name, the composer(s) and the performer?

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I have never used 64-bit Office apps but haven't read anything positive about 64-bit Access. I can't say for certain issue is Office 365 and/or 64-bit, just know I can't get the issue you describe. My understanding is can install 32-bit Access even if other apps are 64-bit.

    Circular As Our Way
    Byrd, Marc and Thompson, Andrew
    Hammock
    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.

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Just how do you do a search?
    Please explain the steps, I cannot see the method a user is meant to use?
    Attached Thumbnails Attached Thumbnails missing form.PNG  
    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

  12. #12
    Join Date
    Jun 2023
    Location
    Jacksonville, FL
    Posts
    26
    That is correct so it should work. Maybe I will try Microsoft Support to see it they can figure it out. Microsoft has said that you can not install 32 bit Access and have 64 bit Microsoft 365 on the same computer.

  13. #13
    Join Date
    Jun 2023
    Location
    Jacksonville, FL
    Posts
    26
    You just click on the binocular icon next to the catalog number on the main form. The form that you referenced is used in conjunction with another process entirely.

  14. #14
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Quote Originally Posted by PlayerPianoMan View Post
    You just click on the binocular icon next to the catalog number on the main form. The form that you referenced is used in conjunction with another process entirely.
    OK. I get the same request as you?

    Multiple times as well.
    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

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    OK,
    It appears it is down to having a filter remaining in your composer subform which was something along the lines of Lookup.Composer = 'b'. Actually
    ([Lookup_ComposerID].[Display]="b")
    I removed that filter and now that search works for me.

    I also amended the code of the requery before I did that, as i was not sure you can requery a subform control?
    Code:
    Private Sub btnSearchCatNumber_Click()
    
    
         Dim strCatNumber As String
         
         strCatNumber = InputBox("Enter Catalog Number", "Catalog Number", TitleNumber)
         
         If strCatNumber = " " Then
              Exit Sub
         End If
         
         Me.Filter = "TitleNumber = """ & strCatNumber & """"
         Me.FilterOn = True
         Me.subfrmSongsB.Form.Requery    'Added Form property?
         
    End Sub
    Edit: I put the code back as it was and it still searches successfully.
    Last edited by Welshgasman; 06-30-2023 at 08:46 AM. Reason: Subform control can be requeried
    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

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

Similar Threads

  1. Replies: 13
    Last Post: 03-02-2018, 12:04 PM
  2. Replies: 8
    Last Post: 02-22-2017, 10:38 AM
  3. Replies: 4
    Last Post: 07-11-2012, 10:31 AM
  4. Replies: 3
    Last Post: 06-02-2012, 07:39 PM
  5. Replies: 7
    Last Post: 05-24-2009, 10:24 AM

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