Repost. Pls Help

  • Thread starter Thread starter Marisa
  • Start date Start date
M

Marisa

Hi,

I have FormA which triggers ReportA via the following syntax:

Dim stDocName As String
Dim strSQL As String

stDocName = "Orders"
strSQL = "[OrderID] =" & Me![OrderID]
DoCmd.OpenReport stDocName, acViewPreview, WhereCondition:=strSQL

The command works only under the following conditions:

Where FormA is linked to tblA and ReportA is linked to tblA

or

where FormA is linked to viewA (qryA) and ReportA is linked to viewA

However, I need the above syntax work with the following conditions:

Where FormA is linked to tblA and ReportA is linked to viewA.
Which is, in my opinion, how it should be done.

Can someone pls direct me to a sound solution.
Thank you.

ACCXP -> SQL2k
 
I would use...

DoCmd.OpenReport "Orders", acViewPreview, , "[OrderID]=" & "'" &
Me![OrderID] & "'"
THIS
WORKS IF FIELD IS TEXT
or

Dim stDocName As String
Dim strLinkCritieria As String

stDocName = "Orders"
strLinkCritieria = "[OrderID] =" & Me![OrderID] CHECK SYNTAX
DoCmd.OpenReport stDocName, acViewPreview, , strLinkCritieria

Hope that helps...
Gina
 
Marisa said:
Hi,

I have FormA which triggers ReportA via the following syntax:

Dim stDocName As String
Dim strSQL As String

stDocName = "Orders"
strSQL = "[OrderID] =" & Me![OrderID]
DoCmd.OpenReport stDocName, acViewPreview, WhereCondition:=strSQL

The command works only under the following conditions:

Where FormA is linked to tblA and ReportA is linked to tblA

or

where FormA is linked to viewA (qryA) and ReportA is linked to viewA

However, I need the above syntax work with the following conditions:

Where FormA is linked to tblA and ReportA is linked to viewA.
Which is, in my opinion, how it should be done.

Can someone pls direct me to a sound solution.
Thank you.

ACCXP -> SQL2k

Provided the RecordSource of the Report contains a record with the same
value of OrderID as the Control on the Form, it should not matter from where
the Control on the Form was populated, or, indeed, if it were typed in by
the user into an unbound Control.

Perhaps your difficult might stem from the Control on the Form and the Field
in the underlying RecordSource having the identical name.

Larry Linson
Microsoft Access MVP
 
Back
Top