Opening to show certain records

Lyncroft

QPR for ever
Local time
Today, 00:08
Joined
May 18, 2002
Messages
168
On a form I've a button to open another form. The new form shows the relevant Participant's records.

Dim stLinkCriteria As String
stLinkCriteria = "ParticipantID=" & Me.Particpantid
DoCmd.OpenForm "tblComments", , , stLinkCriteria


What I want to do is add another criteria to filter it out even more
so that it's something like

stLinkCriteria = "ParticipantID = " & Me.Participantid And INSERT SECOND PART OF FILTER HERE (in my case QuestionID).

I've tried various permutations but without success. I guess it must be possible and it's a question of getting the various quotes in the right place. Any ideas?
 
Last edited:
Sounds like you almost have the answer already. Use something in this form:
stLinkCriteria = "[ParticipantID]=" & Me.Particpantid & " And [UserID]=" & Me.UserID
It's a good idea to delineate the field names with brackets.

Also, note that the above syntax works fine for numeric values in those two fields. If you should need to use a field that contains text values, you will need to surround it with single quotation characters like this:
"[Username]='" & Me.Username & "'"
 
Last edited:
Cheers DC. I spent about 3 hours this afternoon mucking around with that one. Almost put the old foot through the computer screen. I was placing the quotes after the AND.

Ta again.
 

Users who are viewing this thread

Back
Top Bottom