Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing Parameters to Access View
Message
De
11/07/2003 06:34:44
Rene Lovino
Bigfoot Global Solutions, Inc
Cebu, Philippines
 
 
À
10/07/2003 23:22:22
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00809104
Message ID:
00809127
Vues:
27
Noel,

Try this sample:

Dim objCon As ADODB.Connection
Dim objCmd As ADODB.Command
Dim objRst As ADODB.Recordset
Dim objPar As ADODB.Parameter
Dim ConnectionString as String

ConnectionString = "Your connecntion, user, password, etc."
Set objCon = New ADODB.Connection
Set objCmd = New ADODB.Command

objCon.Open ConnectionString
objCmd.ActiveConnection = objCon
objCmd.CommandText = "Your_Access_Query_Name"
objCmd.CommandType = adCmdStoredProc
Set objPar = objCmd.CreateParameter("query_parameter_Name", adChar, adParamInput, 12, "Parameter_value")
objCmd.Parameters.Append objPar
Set objRst = objCmd.Execute


Note the CreateParameter function has the following paremeter:
First parameter is the parameter name of your Query.
Second parameter is the constant which signify the type of your parameter.
Third parameter is the constant that signify the use of your parameter where it is for output, input. On this sample it will ask to input a value.
Fourth parameter is the width of your data type.
Fifth parameter is the value of your parameter.


Rene




Hi to all,

I have an MS-Access Query that accepts a date parameter. If the view is opened in MS-Access, it works fine. You can enter for the parameter.

But how do I pass the parameter from VB Code to retrieve the Query?

Here is my Code:


ObjCon.Open ConnectionString
SQL = "SELECT * FROM qrySALES"
Set RS = ObjCon.Execute(SQL)

... do something here...

RS.Close
ObjCon.Close
Set RS = Nothing
Set ObjCon = Nothing

Where:
qrySALES is a QUERY from MS-Access that accepts a date parameter.

I tried to place a WHERE clause in the SQL statement but it create a syntax error.

Thanks in Advance,

Noel
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform