Executing Stored Procedures

  • Thread starter Thread starter Nexus
  • Start date Start date
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!
 
Try

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

Exagerated for clarity, that's

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