Results 1 to 12 of 12
  1. #1
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154

    Requery

    Dear



    I have error again for me Requery

    I made a combox in entering the "name" , then a button to do Run Query

    It will trigger the Room Query

    Am i making the synatx wrong ?!


    Private Sub cb_htl_AfterUpdate(Cancel As Integer)


    Me.cb_htl.Requery


    End Sub

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Slightly unclear.

    You are using a combobox to select a name?

    Then press a button to run query? Which query?

    Or are you adding a name to the combobox?

  3. #3
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Andy
    Thanks for your feedback

    a) i have a "Select Form" which require user to input a value from a combox
    b) after the input, click the button of Requery
    c) it triggers the Query

    I do the procedure the 1st time, it works but 2nd time, the query is not refresh. ( I am opened the form and query together)
    But when i close either one, it works again

    I tried to go to the input box and made a code, afterupdate - "me.requery". i forgotten once, one of the guru
    show me, the synatx should be me.[fieldname].requery

    But i try this time not working


    In fact , the query result is for a report. I made a report based on the result of this query.
    Can i make a button to print this report?

    Eric

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What is purpose of the combobox - just to enter filter criteria, not to save value into a record? Why are you opening a query object?

    Code behind button to open report like:

    DoCmd.OpenReport "report name", , , "ID=" & Me.cbxID
    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
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Andy

    As want the choice to be dynamic, as user keep inputing into the system

    Combox with the sources from the table is a good choice

    the query is i selected the fields that to be show /display /result to show to our client

    Then a report is made based on this query

    I thought this is the logic

    form -> query -> Report

    But when i try the 2nd time, the query is not able to refresh

    i try to build a code in the combox, afterupdate me.requery but not working

    I just do not know

    Eric

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The combobox only gets updated after you enter or tab out of it. Requery is not the correct solution. And you do not open/run the query unless you want to see the data, but the report is showing it to you so it is unnecessary. June's solution of opening the report directly should solve this.

  7. #7
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Aytee

    Thanks and i tried to do it as per your suggestion

    However, it works only if i close the report after the update.
    If i open the form and the report at the same time, it will not refresh, i have to do refresh manually.

    Is that a way, i can have the refresh automatically everytime when i have new input ?

    Thanks

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why is the report even open when user selects value in combobox? Is database set for Tabbed Documents? I always use Overlapping Windows.

    Are you using a dynamic parameterized query (I never use them) as the report RecordSource? Requerying the combobox will not refresh the query or the report. Command to requery report would be like: Reports!reportname.Requery. The report has to be in ReportView, won't work in PrintPreview.

    What do you mean by 'show to our client' - are they standing there looking over your shoulder as each record is entered and need to see the change in the report?
    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
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    June

    The combox is set on a form - i call it request Report form the input is based on "service type"there is around 5-6 of the kinds

    So, once the user select the service, the report will generate based on this input. I made a query for that and it then lead to the Report

    As you said, i skip the me.requery , and open the form directly. it works

    But when the user go back to the form and reenter a new services while the report is still open, it does not refresh. i think same as the Query.

    I was told that we can do requery and after the user enter the new input, tab, then it will trigger the requery.


    i try me.requery in the afterupdate in the combox but invain.

    I think i must have done something wrong

    Appreciate your comment

    Sncerely
    Eric

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Didn't provide any new info. Didn't answer my questions in post 8. You should read that post again.

    If report RecordSource is NOT a dynamic parameterized query referencing the combobox, following code can work for ReportView or PrintPreview.

    Reports!reportname.Filter = "ID=" & Me.cbxID
    Reports!reportname.FilterOn = True

    Why do you even need to show the report to a user entering data?
    Last edited by June7; 09-03-2017 at 02:49 PM.
    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
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    But when the user go back to the form and reenter a new services while the report is still open, it does not refresh.
    What doesn't refresh - the form or the report? If you are talking about the report, then it is because open reports do not refresh the way forms do when the data changes. If you want the report to reflect changes to the source data, you have to close it and rerun it.

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Eric, are you entering a new record or just entering a value in UNBOUND combobox as filter criteria?

    Report in PrintPreview cannot be requeried/refreshed to display data entered/edited, must be ReportView, otherwise close and reopen report.

    If the combobox is just to select filter criteria, the code to set Filter and FilterOn properties will work for ReportView or PrintPreview.
    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.

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

Similar Threads

  1. AfterUpdate requery does not requery list box
    By ittechguy in forum Programming
    Replies: 5
    Last Post: 09-05-2017, 08:51 AM
  2. Requery
    By Erictsang in forum Programming
    Replies: 6
    Last Post: 08-27-2017, 10:58 AM
  3. requery
    By texas1014 in forum Queries
    Replies: 7
    Last Post: 06-18-2015, 02:55 PM
  4. requery
    By raffi in forum Forms
    Replies: 2
    Last Post: 01-05-2015, 01:22 PM
  5. Requery
    By Grizz2 in forum Queries
    Replies: 2
    Last Post: 05-31-2011, 10:23 AM

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