Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have an MS Access application that contains all tables linked to SQL Server, so in MS Access VBA code I work with those tables very simple, I access them via name, like [Customers].

Also I have a stored procedure in SQL Server called sp_CopyData which I need to call from my VBA code. I want search by name in VBA.
thanks

What I have tried:

SQL
Create PROCEDURE [dbo].[sp_searchh]

 @CustomersName varchar(50)

AS
BEGIN

select Id,age,salary,CustomersName from Table1 where CustomersName =(@CustomersName)

END
Posted
Updated 6-Aug-16 22:12pm
v2

1 solution

You can filter data from linked tables the same way you do that with "normal" tables in MS Access, for example by using Parameters[^]
SQL
PARAMETERS [cusname] CHAR;
SELECT C.Id, C.age, C.salary, C.CustomersName
FROM [Customers] AS C
WHERE C.CustomersName = [cusname];

Conclusion: You don't need to write code to get data from MS SQL Server, because the data are already linked to MS Access database.
For further details, please see:
Everything About Using Parameters from Code[^]
Tips and Techniques for Queries in Access 2007[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900