Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 32
  1. #16
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Note: If I make the changes using the vba then I close the mainform and reopen it - it requeries correctly. Just not while I have the form loaded.

  2. #17
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    Lost me with post 15.

    #13 says qryLibrarySchool has the parameter

    #15 shows qryListSchools is name of the query that returns the fields shown in the query in #6

    Don't know what you mean by 'they are unticked'.

    Still don't understand why you don't use a reference to combobox as dynamic parameter.
    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. #18
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Lost me with post 15.

    #13 says qryLibrarySchool has the parameter

    #15 shows qryListSchools is name of the query that returns the fields shown in the query in #6

    Don't know what you mean by 'they are unticked'.

    Still don't understand why you don't use a reference to combobox as dynamic parameter.
    oh crap, sorry June - didn't notice that.

    qryListSchools is the saved query.

    Then there is the form

    I don't even know where qryLibrarySchool came from - my mind must have wandered..

    The combo box changes the string which I then make the vba write over the sql in the saved query qryListSchools , which then in turn gets used for the unmatched query which the record source of the form uses to run the continuous form that the combo box happens to be listed on.

    I don't want the combo box to filter the current list (the form continuous list) I want it to filter qryListschools.

    You see the form, change the show on the unbound combo box and it is supposed to exclude any of the schools on the form that have a booking in qryListSchools.

    Also when you make a query using the builder and are in design mode you can check or uncheck a field from view yes? well I have ShowsID set to unchecked as I don't care to show it when viewing the list (I just show schoolsid, showtitle and booking date) - which is what I meant to say I guess.

  4. #19
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    "I don't want the combo box to filter the current list (the form continuous list) I want it to filter qryListschools."

    What?

    qryListShools is part of the form RecordSource. Doesn't matter how you alter qryListSchools - through QueryDef or dynamic parameter - the form's dataset is impacted. Why not use the simpler method?
    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. #20
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    "I don't want the combo box to filter the current list (the form continuous list) I want it to filter qryListschools."

    What?

    qryListShools is part of the form RecordSource. Doesn't matter how you alter qryListSchools - through QueryDef or dynamic parameter - the form's dataset is impacted. Why not use the simpler method?
    I would happily use a simpler method

    I began with this:

    https://www.accessforums.net/program...her-39807.html

  6. #21
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    "I don't want the combo box to filter the current list (the form continuous list) I want it to filter qryListschools."

    What?

    qryListShools is part of the form RecordSource. Doesn't matter how you alter qryListSchools - through QueryDef or dynamic parameter - the form's dataset is impacted. Why not use the simpler method?
    The qryListSchools makes a list of schools that have that particular booking (as there are many different types). With that list of schools, using an unmatched query I remove them from the forms list of schools. There is no view of that list on the form that shows the bookings - simply the schools. If I show the bookings then I get duplicates because one school may have more than one booking and of different shows.

  7. #22
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    Sorry, I am totally lost.

    Post 15 shows a query that is form RecordSource. That query includes qryListSchools. You modify qryListSchools through QueryDef code, therefore the form RecordSource is altered.
    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.

  8. #23
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Sorry, I am totally lost.

    Post 15 shows a query that is form RecordSource. That query includes qryListSchools. You modify qryListSchools through QueryDef code, therefore the form RecordSource is altered.
    Yeah you would think so - but it doesn't change... I tried requery but that also doesn't change.

    queryDef does alter qryListSchools - but the form does not update even after requery.

    I have opened up qryListSchools to see the changes made.

    If I close and open the form - it has the proper results - but I would prefer not having to do this.

  9. #24
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    Have you even tried the dynamic parameter with Requery code? If that doesn't work then I have no idea what else to use.
    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.

  10. #25
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Have you even tried the dynamic parameter with Requery code? If that doesn't work then I have no idea what else to use.
    I believe my understanding of what you are asking is completely wrong.

    What do you mean by dynamic parameter just to clarify.

    I've added a picture of the form I am building if that makes it easier in any way...

    Click image for larger version. 

Name:	Capture.JPG 
Views:	4 
Size:	123.6 KB 
ID:	14655

    update - that should say qrySchoolsList not tblSchoolsList! sorry

  11. #26
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    From post 6:

    How would I replace 61 with the value of the combo box txtSHOW?

    My reply in post 7 was:

    Concatenation of variable.

    "WHERE (((tblSchools.NewSchoolsID)<>9389) AND ((tblBookings.BookingDate)>Date()) AND ((tblShows.ShowsID)=" & Me.txtShow & ") AND ((tblBookings.ShowsID)<>5) AND ((tblTeacher.JoiningDateRemoved) Is Null));"

    So my suggestion is instead of code using QueryDef (which seems does not work satisfactorily), use a reference to combobox in the saved query object.
    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.

  12. #27
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Yeah that is what I thought was my understanding.

    Quote Originally Posted by June7 View Post
    From post 6:

    So my suggestion is instead of code using QueryDef (which seems does not work satisfactorily), use a reference to combobox in the saved query object.
    how would you reference it? I can't add that field to the recordsource else it gives me duplicates. Can I still ask it to change the number i.e. 61 in that qrySchoolsList (as seen in Post #15?)

  13. #28
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    I really don't understand why there is an issue.

    Do you have an Access query object with the sql structure shown in post 6?

    Does that query properly retrieve records?

    Do you want to replace static 61 with reference to combobox? (I am assuming it is an unbound combobox used to enter filter parameter.)


    Fields used to filter a query do not have to be 'ticked' - they do not have to show.
    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.

  14. #29
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    I really don't understand why there is an issue.

    Do you have an Access query object with the sql structure shown in post 6?

    Does that query properly retrieve records?

    Do you want to replace static 61 with reference to combobox? (I am assuming it is an unbound combobox used to enter filter parameter.)


    Fields used to filter a query do not have to be 'ticked' - they do not have to show.
    in post 6 - that sql structure is the same structure as qrySchoolsList (it baisically replaces qrySchoolsList when the vba is finished)

    It displays all the bookings with showsid 61 (or other) correctly (this is qrySchoolsList/VBA string)

    Yes unbound control

    Think of it that I started off with a continuous forms that just listed all the schools, then to remove some schools I added qrySchoolsList to it to filter out those few schools with 61

  15. #30
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    So your answers are:

    There is an Access query object with that SQL statement.

    You want code to replace the sql of the query object to include a parameter from combobox.


    My response:

    Do not use VBA.

    Use a reference to combobox in the Access query object.

    If the dynamic parameter in query object does not work then there is something else seriously wonky about the query and no amount of VBA will help it anyway.
    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.

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

Similar Threads

  1. Replies: 5
    Last Post: 08-03-2012, 04:20 PM
  2. Replies: 7
    Last Post: 07-14-2012, 01:02 AM
  3. how to refer to if attachment count is zero vba
    By aspen in forum Programming
    Replies: 3
    Last Post: 05-03-2012, 05:56 AM
  4. Refer to ONLY THE MONTH??
    By taimysho0 in forum Programming
    Replies: 18
    Last Post: 01-27-2012, 01:12 PM
  5. Replies: 10
    Last Post: 08-08-2011, 01:55 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