Using MS Access/StLinkCriteria - 2 fields
Expert: Scottgem - 2/1/2005
QuestionDear Scottgem,
Hope you can help...
I'm building an Event at Access to visualize a report (called Carttões) linked to the data of two fields: [codigorodada] and [caixas].
I only know how to set the linking criteria for one field, how could I put the StLinkCriteria for both fields?
-------------------------------------
Private Sub Comando184_Click()
On Error GoTo Err_Comando184_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Cartões"
stLinkCriteria = "[codigorodada]=" & Me![codigorodada]
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
Exit_Comando184_Click:
Exit Sub
Err_Comando184_Click:
MsgBox Err.description
Resume Exit_Comando184_Click
End Sub
-------------------------------------
Thanks in advance!
Tiago.
AnswerFrankly I wouldn't do it that way. Since you are running this report from a form, that means the form is open. What I would do is base my report on a query. In the criteria section of the query, use:
=Forms!formname!controlname
where formname is the name of your form and controlname the name of your query. The query will then be filtered based on the values of the current record. This is they I do almost all my filtered reports.
If you want to use the Filter parameter of the OpenReport method, the solution though is simple:
stLinkCriteria = "[codigorodada]=" & Me![codigorodada] & " AND [caixas] = " & Me![caixas]
HTH
Scott<>