I have use in the button the following:
--------------------------------------------------------
Dim sql As String
sql = "EXEC [ORD-qInsertOrderFromFile-1]
Forms.[ORD-FInsertOrderFromFile].[OrderID],
Forms.[ORD-FInsertOrderFromFile].[ClientID]"
CurrentProject.Connection.Execute sql
--------------------------------------------------------
My SP is:
--------------------------------------------------------
CREATE PROCEDURE [ORD-qInsertOrderFromFile-1]
@OrderID nvarchar(40), @ClientID int
AS
INSERT INTO [ORD-Orders] (TypeID, OrderID, ClientID)
SELECT 'ORD', @OrderID, @ClientID
--------------------------------------------------------
When I press the button I get error:
--------------------------------------------------------
Run-time error '-2147217900 (80040e14)'
Incorrect Syntax near '.'
Dimitris
Ï "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam
please)> Ýãñáøå óôï ìÞíõìá For inserting a record, you can call CurrentProject.Connection.Execute:
Dim sql as string
sql = "EXEC qINSERTORDER '" & [Forms]![FINSERTORDER ]![ORDERID] & "'"
CurrentProject.Connection.Execute (sql)
or you can open a recordset like previously and use the AddNew and
Update command:
...
cmdMenu.CommandType = adCmdText.
cmdMenu.CommandText = "Select * From Orders Where 1=0"
cmdMenu.AddNew
cmdMenu ("ORDERID") = [Forms]![FINSERTORDER ]![ORDERID]
cmdMenu.Update
...
If you want to get the identity value of the newly inserted record,
read it from the recordset after the Update command. Or course,
[Forms]![FINSERTORDER ]![ORDERID] can be replaced with Me.OrderID where
possible.
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail:
http://cerbermail.com/?QugbLEWINF
"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message To my knowledge, the InputParameters is only for the record source of
a bound form or the rowsource of a control on that form (bound or
unbound).
If you want to call a SP from a button, you have to use ADO objects;
something like:
Dim cmdMenu As ADODB.Command
Set cmdMenu = New ADODB.Command
Set cmdMenu.ActiveConnection = CurrentProject.Connection
cmdMenu.CommandType = adCmdStoredProc ' or: adCmdText.
cmdMenu.CommandText = "MyStoredProcedure"
cmdMenu.Parameters.Append cmdMenu.CreateParameter("@IdOrganisme", _
adInteger, adParamInput, , aIdOrganisme)
Dim rsMenu As ADODB.Recordset
Set rsMenu = New ADODB.Recordset
rsMenu.CursorLocation = adUseClient ' Default location:
adUseServer
rsMenu.Open cmdMenu, , adOpenStatic, adLockOptimistic
Do While Not rsMenu.EOF
Debug.Print rsMenu ("FirstField")
rsMenu.MoveNext
Loop
rsMenu.Close
set rsMenu = Nothing
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail:
http://cerbermail.com/?QugbLEWINF
I have a SP:
CREATE PROCEDURE qINSERTORDER @ORDERID nvarchar(40)
AS
INSERT INTO Orders (ORDERID)
SELECT @ORDERID
I have a form FINSERTORDER with a Field ORDERID and a button to call
the SP. In Input parameters I have:
ORDERID nvarchar(40) = [Forms]![FINSERTORDER ]![ORDERID].
When I press the button I am asked to enter parameter value for
ORDERID.
Thanks
Dimitris