Results 1 to 13 of 13
  1. #1
    verhp11 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    6

    Execute query opening a form

    Hello all,
    I have a question, I have a form from where I would like to publish data from a parameter query.
    I have six textboxes which should be filled with output from the parameter query , for each textbox there the query should be called with a different value as parameter. I've been busy with trial and error but just not get it to work.

    Any tips?

    Thanks in advance,



    Peter

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Try binding the form to the query and the textbox controls to the fields of the query.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    verhp11 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    6
    Hi Bob,
    Thank you, for one outcome query this works, but how can I pass a parameter to the query to show the outcome in the textbox?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by verhp11 View Post
    Hi Bob,
    Thank you, for one outcome query this works, but how can I pass a parameter to the query to show the outcome in the textbox?
    Use TempVars?
    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

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by verhp11 View Post
    Hi Bob,
    Thank you, for one outcome query this works, but how can I pass a parameter to the query to show the outcome in the textbox?
    Not sure what you mean by this but I'm guessing that what you want could be done by having a button, perhaps in the header section which runs one line of code:

    Me.Requery
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    struggling to understand your description since you should just need to run the query once or perhaps approach from a different direction. Suggest provide some example data, the sql of your parameter query and the outcome required from that example data for the six textboxes on your form

  7. #7
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Can you upload the database? It makes it much easier when we can see the structure of your tables etc...
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I think the request is how to get data typed into form controls into the query fields as parameters. In other words, when the query is run, it looks to the form controls for the parameters. It would help a lot if verhp11 could clarify the request.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    verhp11 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    6
    Quote Originally Posted by mike60smart View Post
    Can you upload the database? It makes it much easier when we can see the structure of your tables etc...
    I tried, but got a message that the DB is to big to upload.
    I would try to clarify:


    1. There is a table within the database which holds records from 6 different locations (location is a field in the record).
    2. In the form I have 6 textboxes where I want to show a count of records of each location.
    3. When I start the form I want to fire a query for each textbox to fill with the count of records for that specific location.


    The question is how to achieve that. I hope that makes is a bit clearer? Sorry for the fuzz

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    I tried, but got a message that the DB is to big to upload.
    Run Compact and Repair and then Zip the db.
    Have you tried using DCount() as the Control Source of your textboxes.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by verhp11 View Post
    I tried, but got a message that the DB is to big to upload.
    I would try to clarify:


    1. There is a table within the database which holds records from 6 different locations (location is a field in the record).
    2. In the form I have 6 textboxes where I want to show a count of records of each location.
    3. When I start the form I want to fire a query for each textbox to fill with the count of records for that specific location.


    The question is how to achieve that. I hope that makes is a bit clearer? Sorry for the fuzz
    I would just use a Dcount().
    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
    verhp11 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    6
    Quote Originally Posted by Bob Fitz View Post
    Run Compact and Repair and then Zip the db.
    Have you tried using DCount() as the Control Source of your textboxes.
    Hi all, I checked Dcount out, and got it to work.
    You do have to set focus on the textbox when loading, but it works.

    Thank you very much, you made a Access junior happy

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by verhp11 View Post
    Hi all, I checked Dcount out, and got it to work.
    You do have to set focus on the textbox when loading, but it works.

    Thank you very much, you made a Access junior happy
    Not if you set them as expression in the control source?
    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

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

Similar Threads

  1. Replies: 6
    Last Post: 01-04-2018, 09:58 PM
  2. RunSQL vs. QueryDef.Execute vs. CurrentDB.Execute
    By caubetiep1337 in forum Queries
    Replies: 8
    Last Post: 12-16-2015, 05:35 PM
  3. Replies: 10
    Last Post: 02-27-2015, 11:28 AM
  4. Opening form with parameter query
    By Lowell in forum Forms
    Replies: 5
    Last Post: 04-01-2012, 04:46 PM
  5. Replies: 3
    Last Post: 05-02-2011, 07:34 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