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

    Parameter from form to queries

    Dear all

    I wonder if anyone can advise me what was wrong as the input in the form does not activiate the query to get the result

    I managed to get the combo box , run query button, and place the following in Query but it does not work

    Appreciate your help

    The SQL is

    SELECT Hotel_T.G_Code, Hotel_T.O_Code, Hotel_T.PAIRNO, Hotel_T.Surname, Hotel_T.FirstNameFROM Hotel_T
    WHERE (((Hotel_T.G_Code)=[Forms]![GroupSelector]![Grp_selector]) AND ((Hotel_T.O_Code)=[Forms]![GroupSelector]![Grp_selector]));




    Click image for larger version. 

Name:	Group_selector.JPG 
Views:	32 
Size:	35.5 KB 
ID:	29954

    Click image for larger version. 

Name:	Query.JPG 
Views:	32 
Size:	72.7 KB 
ID:	29955
    Attached Thumbnails Attached Thumbnails Capture.JPG  

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Is the value "G0264" in the first column of your row source for the combobox? Is the bound column set to 1?

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Your SQL has 2 criteria, comparing 2 different fields to the same combo. Is that appropriate?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    Do you use any lookups set on fields in table?

    Continued from https://www.accessforums.net/showthread.php?t=67559

    Apparently it wasn't working even when there was only 1 field in the criteria.

    If you want multiple fields referencing same control, probably should use OR operator.
    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
    I have set the column to 1 and need only 1 criteria ( i try to make it column=2,still not workin

    SELECT Hotel_T.G_Code, Hotel_T.PAIRNO, Hotel_T.Surname, Hotel_T.FirstName, Hotel_T.PAIRING, Hotel_T.HOTELNAME, Hotel_T.CHECKIN, Hotel_T.CHECKOUT, Hotel_T.NITE, Hotel_T.ROOM_TYPE, Hotel_T.REMARKS, Hotel_T.RM_PRICE, Hotel_T.TTL_PRICE, Hotel_T.PAY_MOD, Hotel_T.O_Code
    FROM Hotel_T
    WHERE (((Hotel_T.O_Code)=[Forms]![Form1]![Grp_selector]));

    But it is not working
    any idea ?
    Attached Thumbnails Attached Thumbnails Combox_clm1.JPG  

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    My guess:
    The value in your combo is [grouping].[ID] because that is the first field in the SELECT order and you've bound column 1.
    Yet your query WHERE clause is comparing O_Code to grouping.id. Without knowing what those fields contain, it's just a guess but the names suggest that there can't be a match.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    What is the SQL behind the "Hotel Query" button (On Click event)?

    Assuming the SQL you have posted is the query SQL, where are you calling it from? In order for the query to work, the form has to be open and has to have a value in the search combo box Grp_Selector.

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

    so, how can I resolve it ?

    Changed the order in Grouping ID to place in the last column
    or change the Bound column to ??

    Eric

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

    I have amended it as follows:

    SELECT Hotel_T.G_Code, Hotel_T.O_Code, Hotel_T.PAIRNO, Hotel_T.Surname, Hotel_T.FirstName, Hotel_T.PAIRING, Hotel_T.HOTELNAME, Hotel_T.CHECKIN, Hotel_T.CHECKOUT, Hotel_T.NITE, Hotel_T.ROOM_TYPE, Hotel_T.REMARKS, Hotel_T.RM_PRICE, Hotel_T.TTL_PRICE, Hotel_T.PAY_MOD
    FROM Hotel_T
    WHERE (((Hotel_T.G_Code)=[Forms]![Form1]![Grp_selector]));

    I have set the column =1

    Open the form1 and click run Query
    the query does not work

  10. #10
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I have set the column =1
    Try setting it to 2 - O_Code is the second column in the Combo Box SQL.

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

    I have solved it with changing the order of the O_Code and G_code
    I make it

    But i found that i have to refresh the queryy many time in order to get the result.
    How can i do the auto refresh ?

    Eric

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    Should only have to refresh query once after selecting item in combobox.

    Why not bind the query to a form and put the combobox on that same form? Review http://allenbrowne.com/ser-62.html
    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.

  13. #13
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    I have set the column =1
    Open the form1 and click run Query
    the query does not work
    Sorry for not getting back here - have been busy with other projects. You are in good hands though.
    The fix you used is fine; altering the query field left to right order or the bound column number is fine. Your choice.

  14. #14
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Quote Originally Posted by June7 View Post
    Should only have to refresh query once after selecting item in combobox.

    Why not bind the query to a form and put the combobox on that same form? Review http://allenbrowne.com/ser-62.html
    As I have to query the result and convert it to excel, send this file to client. Hence, I made a form with this combo, and run the query on other.

    If I bound the query as inform, can I do the same. Convert the result is not excel?

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    What method are you using to export to Excel?

    Form probably not best vehicle for that. Export query or a report bound to that query.
    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 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 11-19-2012, 05:42 PM
  2. Replies: 13
    Last Post: 01-10-2012, 09:56 AM
  3. Can you use wildcards in parameter queries?
    By noaccessguru in forum Queries
    Replies: 5
    Last Post: 05-24-2011, 08:44 PM
  4. parameter queries
    By cpride in forum Access
    Replies: 1
    Last Post: 03-23-2011, 09:21 PM
  5. Running parameter queries from VBA
    By John Southern in forum Programming
    Replies: 6
    Last Post: 03-25-2010, 10:24 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