Executing Stored Procedures

N

Nexus

I have a stored procedure i SQL which I have created. I
want to be able to execute this procedure in VBA, thus
allowing it to read the values from the form's textboxes
and storing it into the parameter. How do I do so??

This is the codes in my stored procedure:

CREATE PROCEDURE insert_vendor

@VendorID VARCHAR (6),
@CompanyName VARCHAR (80)
AS

INSERT INTO tblVendors (VendorID, CompanyName) VALUES
(@VendorID, @CompanyName)

GO

This are the codes that I've tried out in VBA:

DoCmd.RunSQL "EXECUTE insert_vendor @VendorID =
strVendorID, @CompanyName = strCompanyName"

Thanks!
 
D

Douglas J. Steele

Try

DoCmd.RunSQL "EXECUTE insert_vendor @VendorID = '" &
strVendorID & "', @CompanyName = '" & strCompanyName & "'"

Exagerated for clarity, that's

DoCmd.RunSQL "EXECUTE insert_vendor @VendorID = ' " &
strVendorID & " ', @CompanyName = ' " & strCompanyName & " ' "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top