Share via

Filter report based on textbox value

Anonymous
2011-07-23T20:34:48+00:00

I have a command button on my form and would like to run a report filtered on the contents of a tectbox (ContactName) but not having mush luck.

Private Sub Command13_Click()

 Dim strCriteria As String

strCriteria = Me.ContactName.Value

' open report in print preview

 DoCmd.OpenReport "rptHoldingsList", View:=acViewPreview, WhereCondition:=strCriteria

End Sub

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-07-23T21:16:52+00:00

I wrote:

DoCmd.OpenReport "rptHoldingsList", acPreview, , "ContactName= '" & Me.ContactName & "'"

Please replace strCriteria with ContactName and report back.

Was this answer helpful?

0 comments No comments

8 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-07-23T21:12:36+00:00

    Here is the line:

    DoCmd.OpenReport "rptHoldingsList", acPreview, , "strCriteria= '" & Me.ContactName & "'"

    and it returns an Enter Parameter dialog

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-07-23T21:01:49+00:00

    Please check that you have the quotes in this part right.

    '" & Me.ContactName & "'"

    [SingleQuote][DoubleQuote] & Me.ContactName & [DoubleQuote][SingleQuote][DoubleQuote]

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2011-07-23T20:54:53+00:00

    Had to replace ContactName= with strCriteria but it returns all records

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2011-07-23T20:47:10+00:00

    Hi

    You may like to try this:

    DoCmd.OpenReport "rptHoldingsList", acPreview, , "ContactName= '" & Me.ContactName & "'"

    Was this answer helpful?

    0 comments No comments