Results 1 to 4 of 4
  1. #1
    fluppe is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    48

    Set paramter for a query as a Control-Value of a form

    Hello,



    i have a question concerning setting of parameters in a query:

    I have a query with a parameter and a form with a control ... however, i want the value of the control to be used as parameter in the query.

    For example a checkbox "chkb". Now i specify a query as RecordSource (or ...set ... i'm not sure) for a subform and i want it to change the parameter-value with the value of "chkb".

    Is it just necessary to assign the name of the parameter correct (in the query-definition, put smth like [Me].[chkb].[Value]), or do i have to set the parameter in VBA ?
    And anyway, is it clear what i mean ?

    Best regards,

    ...

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    No the ME is useless and really shouldnt be used. It ONLY work inside the form its in.
    For queries you must use the ENTIRE path... forms!frmMyForm!chkb
    (no need for .value, its the default)

    Try to name controls so they are readily understandable, like chkInsured, or cboState. (i know yours is only an example)
    That way you know when you examine the query.

    Subform is a longer path: forms!frmMyForm!subform!forms!chkb
    ALWAYS USE THE BUILDER TO REFERENCE CONTROLS. (the magic wand with elipsis) IT WILL GET IT ALL CORRECT.

  3. #3
    fluppe is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    48
    Hi,

    thanks for your answer. The BUILDER works great so far, but i think my setting makes it a little complicated.

    I have a Form with an underlying table ... for each record in the table (for example record_1) there is a button and when i click it, the next Form opens. The next form is designed to edit entries related to the record in the first form, HERE: record_1.

    First of all, when i click the button, the next form is opened, then i set an appropriate value into a control on the opened Form, that references the related entries ... some ID or what of record_1
    That works as well ...
    But the query is not updated according to that value. And a requery does not seem to solve that ...

    So i think it should be something about the sequence in which i do the things ... but i can't get, what it is exactly ...

  4. #4
    fluppe is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    48
    ... i think i have got it now ... seems alright if i set things up and requery all in the button_click-fcn, and not in the Open_fcn ...
    Thanks a lot for your answer and comments and best regards,

    ...

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

Similar Threads

  1. Replies: 2
    Last Post: 01-30-2013, 07:34 PM
  2. Replies: 3
    Last Post: 03-29-2012, 12:40 PM
  3. Use form control value as parameter for query
    By jpkeller55 in forum Access
    Replies: 2
    Last Post: 02-07-2012, 06:09 PM
  4. How to run a query from a control on a form
    By flsticks in forum Forms
    Replies: 2
    Last Post: 05-13-2011, 05:58 AM
  5. using form's control as criteria in a query
    By brandonb in forum Access
    Replies: 0
    Last Post: 06-09-2009, 02:52 PM

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