Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Apr 2002
    Amersfoort, Utrecht, Netherlands
    Thanked 0 Times in 0 Posts

    query criteria from formfield (97nl)

    Hello all,

    I have a report that is based on a query
    This report is printing information that is currently visable on a form
    Now I want to have a button on the form that will open the report in preview mode, but I need to set the criteria of the formquery to the callnummer field of the form, so that it will only show the information of the current call on the screen.

    How do I set a query criteria from a fromfield value?

    Thank in advance for your reaction.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: query criteria from formfield (97nl)

    The DoCmd.OpenReport method has a WhereCondition argument.

    DoCmd.OpenReport "rptMyReport", acViewPreview, , "CallNumber = " & Me.CallNumber

    Here, rptMyReport is the name of the report, and CallNumber is the name of the field in the record source of the form and report. I have assumed that it is a number field. If it is text, you must enclose the value in quotes Chr(34):

    DoCmd.OpenReport "rptMyReport", acViewPreview, , "CallNumber = " & Chr(34) & Me.CallNumber & Chr(34)

Posting Permissions

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