VBA Code to open a form with 2 where conditions

I need to open a form to a specific record using a command button via VBA code from another form. In the Onclick event,;

Private Sub CmdOpenForm_Click()
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "NotesDatasheetForm"    
    stLinkCriteria = "[note_uid]=" & Me![note_uid]& AND "[report_uid]=" & Me.Report_id_combo.Column(0)
    DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

It keeps putiing syntax error. How do i fix the syntax error?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
if both fields are Number Type data use this

stLinkCriteria = "[note_uid]=" & Me![note_uid] &" AND [report_uid]=" & Me.Report_id_combo.Column(0)

if both fields are Text Type data use this

stLinkCriteria = "[note_uid]='" & Me![note_uid] &"' AND [report_uid]='" & Me.Report_id_combo.Column(0) & '''"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
    stLinkCriteria = "[note_uid]= " & Me![note_uid] & " AND " & [report_uid] = " & Me.Report_id_combo.Column(0)"

Open in new window

peterslove53Author Commented:
Thanks alot. Works
Dale FyeOwner, Developing Solutions LLCCommented:
I always put a line between the line that defines my criteria and the line that opens the form (at least during debugging).

    stLinkCriteria = "[note_uid]=" & Me![note_uid] _
                             & "AND [report_uid]=" & Me.Report_id_combo.Column(0)
    debug.print stLinkCriteria
    DoCmd.OpenForm stDocName, , , stLinkCriteria

In this case, you had a " in the wrong place.  You had it between the AND and the [report, when it should have been in front of the AND, as I have indicated above.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.