2 replies
by miss kitty
Here is an example of the syntax showing the passing of parameters (values in vb fields) to an Access query:
Dim objConn As New ADODB.Connection
Dim objCmd As New ADODB.Command
Dim objRS As New ADODB.Recordset
Dim objParam As ADODB.Parameter
Dim count As Integer
'set up the database pointer
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=E:\ACCESS\CONTRACT HAULERS\HAULER.mdb;User ID=ADMIN"
objRS.CursorType = adOpenDynamic
objRS.LockType = adLockOptimistic
'setting the Active Connection for the command object
objCmd.ActiveConnection = objConn
'Providing the query name as commandtext
objCmd.CommandText = "[SINGLE TICKET QUERY]"
objCmd.CommandType = adCmdStoredProc
'create the parameter and populate it
Set objParam = objCmd.CreateParameter("@TICKET_NUM", adChar, adParamInput, 6, 0)
objCmd.Parameters.Append objParam
Set objParam = objCmd.CreateParameter("@VENDORID", adChar, adParamInput, 6, 0)
objCmd.Parameters.Append objParam
'Assign the values for the parameters
objCmd.Parameters("@TICKET_NUM").Value = CStr(txtTicket)
objCmd.Parameters("@VENDORID").Value = CStr(txtVendor)
'Set the recordset to the command object result
Set objRS = objCmd.Execute
by mustaqeem1
another easy way for Access Report through VB6:
Private Sub Command1_Click()
Dim ac As Access.Application
Set ac = New Access.Application
ac.OpenCurrentDatabase
ac.Visible = True
ac.DoCmd.OpenReport , acViewPreview
End Sub
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending