Hi
This is what I have:
Const strLcQUERY_NAME As String = "AwbEnquirynull"
Const strLcQUERY_PARAMETER1_NAME As String = "StrName" ' This can be anything
Const strLcQUERY_PARAMETER2_NAME As String = "NodeType" ' This can be anything
Dim cmd As ADODB.Command: Set cmd = New ADODB.Command
Dim prm As ADODB.Parameter
Dim strLvDoB As String
With cmd
' Attach the command to a connection
.ActiveConnection = cnMvConnection
' Create the parameters (Name & Dob) which will be used
' by the query to insert
' Name, data type, parameter type, length of parameter, value of parameter
Set prm = .CreateParameter(strLcQUERY_PARAMETER1_NAME _
, adVarChar _
, adParamInput _
, Len(strName) _
, strName _
)
Call .Parameters.Append(prm)
' Name, data type, parameter type, length of parameter, value of parameter
Set prm = .CreateParameter(strLcQUERY_PARAMETER2_NAME _
, adVarChar _
, adParamInput _
, Len(NodeType) _
, NodeType _
)
Call .Parameters.Append(prm)
' Tell the command that it is about to execute a Query
.CommandType = adCmdStoredProc
' Tell the command the name of the query to be executed
.CommandText = strLcQUERY_NAME
' Execute the query
.Execute
End With
Report.WindowState = crptMaximized
Report.ReportFileName = "MyReport.RPT"
intTemp = Report.PrintReport
I do a similar thing in SQL Server and the report get printed.
I want to do the same thing with Access 97 DB. Is that possible?
Every time I try to run the code it says : Too few parameters. Expected two. This I guess is because the report does not get the parameters it is expecting.
My report depends on AwbEnquiry query.
Any suggestions guys.
This is what I have:
Const strLcQUERY_NAME As String = "AwbEnquirynull"
Const strLcQUERY_PARAMETER1_NAME As String = "StrName" ' This can be anything
Const strLcQUERY_PARAMETER2_NAME As String = "NodeType" ' This can be anything
Dim cmd As ADODB.Command: Set cmd = New ADODB.Command
Dim prm As ADODB.Parameter
Dim strLvDoB As String
With cmd
' Attach the command to a connection
.ActiveConnection = cnMvConnection
' Create the parameters (Name & Dob) which will be used
' by the query to insert
' Name, data type, parameter type, length of parameter, value of parameter
Set prm = .CreateParameter(strLcQUERY_PARAMETER1_NAME _
, adVarChar _
, adParamInput _
, Len(strName) _
, strName _
)
Call .Parameters.Append(prm)
' Name, data type, parameter type, length of parameter, value of parameter
Set prm = .CreateParameter(strLcQUERY_PARAMETER2_NAME _
, adVarChar _
, adParamInput _
, Len(NodeType) _
, NodeType _
)
Call .Parameters.Append(prm)
' Tell the command that it is about to execute a Query
.CommandType = adCmdStoredProc
' Tell the command the name of the query to be executed
.CommandText = strLcQUERY_NAME
' Execute the query
.Execute
End With
Report.WindowState = crptMaximized
Report.ReportFileName = "MyReport.RPT"
intTemp = Report.PrintReport
I do a similar thing in SQL Server and the report get printed.
I want to do the same thing with Access 97 DB. Is that possible?
Every time I try to run the code it says : Too few parameters. Expected two. This I guess is because the report does not get the parameters it is expecting.
My report depends on AwbEnquiry query.
Any suggestions guys.