AllExperts > Using MS Access 
Search      
Using MS Access
Volunteer
Answers to thousands of questions
 Home · More Using MS Access Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Scottgem
Expertise
I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience
I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > StLinkCriteria - 2 fields

Using MS Access - StLinkCriteria - 2 fields


Expert: Scottgem - 2/1/2005

Question
Dear 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.

Answer
Frankly 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<>

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.