pokeymonsc
Technical User
I've created a pass-through query to a stored procedure on SQL-Server using Query Designer in access. I've done this with another SP and the method works fine. The code for this SP is:
EXECUTE spDeleteChildRecords [mmes_number]
What I'm unsure about this time is the correct code to pass a parameter (mmes_number) to the SP. I have a button on my Base form:
Dim stDocName As String
stDocName = "DeleteChildRecords"
DoCmd.OpenQuery stDocName, acNormal, acEdit
and this will run the SP but I haven't worked out how to pass the parameter to the query and on to the SP. What I want to do is pass the 'mmes_number' that is in a textbox on the form where my button as a parameter to the query and on to the SP. The 'OpenQuery' method in the button code doesn't allow for this and playing with the EXECUTE code (EXECUTE spDeleteChildRecords (Basedata.mmes_number))(Form.txtbox) didn't work either. Any suggestions?
Some of the code in the SP are as follows:
CREATE PROCEDURE dbo.spDeleteChildRecords (@id1 varchar(10))
AS
BEGIN
IF @id1 IS NOT NULL
DELETE FROM BASE_DATA WHERE MMES_NUMBER = @id1
(Repeated with 21 other tables)
END
GO
There are a lot of tips in the forum on how to use VBA code to access the server directly and run the SP, but nothing on using the query designer to set up the pass-through and how to send a parameter to the query.
EXECUTE spDeleteChildRecords [mmes_number]
What I'm unsure about this time is the correct code to pass a parameter (mmes_number) to the SP. I have a button on my Base form:
Dim stDocName As String
stDocName = "DeleteChildRecords"
DoCmd.OpenQuery stDocName, acNormal, acEdit
and this will run the SP but I haven't worked out how to pass the parameter to the query and on to the SP. What I want to do is pass the 'mmes_number' that is in a textbox on the form where my button as a parameter to the query and on to the SP. The 'OpenQuery' method in the button code doesn't allow for this and playing with the EXECUTE code (EXECUTE spDeleteChildRecords (Basedata.mmes_number))(Form.txtbox) didn't work either. Any suggestions?
Some of the code in the SP are as follows:
CREATE PROCEDURE dbo.spDeleteChildRecords (@id1 varchar(10))
AS
BEGIN
IF @id1 IS NOT NULL
DELETE FROM BASE_DATA WHERE MMES_NUMBER = @id1
(Repeated with 21 other tables)
END
GO
There are a lot of tips in the forum on how to use VBA code to access the server directly and run the SP, but nothing on using the query designer to set up the pass-through and how to send a parameter to the query.