Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2003
    Posts
    45

    Question Unanswered: How to set Report parameter in Command Button

    Hi everione,

    I have an easy question (but I still don't know the answer ;-)

    I have a report that shows details about particular emploee.
    I select the emploee by setting parameter in the record source query of that report - Emploee_ID = textboxvalue in Form#1.

    The problem is that I want to run this report from five different forms and parameter should be one of the fields in every form.
    Unfortunately VB is not my mother tongue ;-) so all I can do now is to make five copies of that report and set different parameters in their recordsource queries.
    But that sounds stupid - I'm sure that there is a way to use the same report and set that parameter not in the recordset query but in the OnClick event of one Button in everyone of my five forms. /I suppose that it should be something like: open report, filter on Emploee_ID = textboxvalue/

    If someone can tell me the function that I should use and its sintaxis I will be extremely gratefull.
    THANK YOU VERY MUCH IN ADVANCE.

  2. #2
    Join Date
    Feb 2007
    Posts
    348
    You could use the docmd.openreport with a where clause.

  3. #3
    Join Date
    May 2005
    Posts
    1,191
    Quote Originally Posted by pivodrinkov
    If someone can tell me the function that I should use and its sintaxis I will be extremely gratefull.
    To expand on starkmann's post, you can do something like the following:
    Code:
    Dim strWHERE As String
    strWHERE = "((TblName.[FldName]) = '" & Me.TxtBoxName & "')"
    DoCmd.OpenReport "RptName", acViewPreview, , strWHERE
    I've also posted some an example with a little more flexibility in the code bank. Let us know how it turns out.
    Me.Geek = True

  4. #4
    Join Date
    Feb 2007
    Posts
    348
    Sorry, I probably should have sad more. I find sometimes I totally misinterpret the question so I try to make sure I'm on the right path before going on.

  5. #5
    Join Date
    Jun 2003
    Posts
    45
    Thanks guys,
    Everithing is OK now. It was esier than I thought.
    And don't you worry starkmann - I did it right after your first post ;-)
    I should have done it all by miself but I'm to lazy to read MS Access Help...
    THANK YOU BOTH FOR YOUR HELP

Posting Permissions

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