• query criteria from formfield (97nl)

    Author
    Topic
    #406580

    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.

    Viewing 1 reply thread
    Author
    Replies
    • #844263

      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)

    • #844264

      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)

    Viewing 1 reply thread
    Reply To: query criteria from formfield (97nl)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: