Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2004
    Posts
    100

    Unanswered: record source of a form

    Hello,

    I am wondering if its possible to add a where condition to the record source of a form?

    I have the table requests having an attribute named country. For that table i have a form showing all attributes of the table.
    When logging in to the db I retrieve the user information out of the person table which also has an attribute named country.

    So what I want to accomplish now is that based on the user's country I only want to display those records of the request table having the same country like the logged in user.

    How can I accomplish that. Remark: I only use the record source property of a form to display the records. I do not have a view of the request table. And because a view will demand too many changes to my existing forms i don't want to user one.

    So my thought was to add a where condition to the record source of the form. Is that possible? and how?
    Thanks in advance
    Regards
    Proximus

  2. #2
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    In the query feeding the form you can do it

    Or...

    Use the where clause of the docmd.openform command....

    Greetz

  3. #3
    Join Date
    Apr 2004
    Posts
    100
    hmm. I guess I will need more help with that. Could you kindly try to exmplain your suggestion in a bit more detail. Thank you very much in advance.
    Note: the record source of the request form looks like this. (in the properties form): record source = REQUEST

    is it possible to do something like:
    record source = REQUEST where request.country = thecountryiwant

    Please help

  4. #4
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    I you lookup the openform command in the access help i am pretty sure you can figure it from there... but here goes...

    something like so
    DoCmd.OpenForm "YourForm", , , "[yourfield] = 'SOmeValue'"

    "[yourfield] = 'SOmeValue'" would be your where clause....

    Greetz

  5. #5
    Join Date
    Apr 2004
    Posts
    100
    ok. I guess I got you.
    However I don't know where to write that code.

    I have the main form request with the subform resource with the subform resource line.

    At startup of the db the form request is loaded. After deployment this form should automatically open at first. During implementation I open it by double clicking on the form name.

    And the condition should work for the subforms resource and resource line as well

  6. #6
    Join Date
    Jun 2004
    Location
    Seattle, WA
    Posts
    601
    I believe you can attach that to a command button, then on the OnClick Property of the command button use that code?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •