Results 1 to 2 of 2

Thread: how to pass values to a calling stored procedure

  1. #1
    Join Date
    Nov 2006
    Posts
    3

    Unhappy how to pass values to a calling stored procedure

    Currently i am working in a project of report generation in MS ACCESS.

    The tables are in sql server 2000.
    I have to write stored proc in ms access.

    Illustration:
    I am having a stored proc as follows

    name: myproc
    -------------------
    Create procedure my_proc
    @f1 char(1),
    @f2 char(5)
    As
    select * from table1 where field1=@f1 and field2=@f2
    ________________________________________________
    and calling proc
    name: call_myproc

    execute my_proc 'A','2004'

    If i am getting the vales of field1/@f1 and field2/@f2 from forms in ms access.

    I have to get the values from forms in ms access.

    I have to write the calling proc as follows

    my_proc [forms]![form_a].[Combo4],[forms]![form_a].[text12]

    But ms access throws syntax error.

    How is it possible to pass values from ms access FORMS to a calling stored procedure.

    I have followed the way of creating and executing the stored procedure as given in the article as follows.
    http://www.databasejournal.com/featu...0895_3363511_1

    As per the given link. They did not give values dynamically.

    could you please help me to fix this problem ?

    regards,
    Krishna

  2. #2
    Join Date
    Nov 2006
    Posts
    7
    I'm not 100% sure how access works with SQL Server, but I am gonna make the assumption that you can execute select statements in the usual manner by constructing an sql statement string, something like:
    Code:
    sqlstr = "select username from tbl_users"
    connection.execute(sqlstr)
    Based on the above you should be able to do something like:
    Code:
    sqlstr = "exec my_proc " & [forms]![form_a].[Combo4] & ", " & [forms]![form_a].[text12]
    connection.execute(sqlstr)
    Please note none of the above is exact code, and I am not 100% sure of Access's capabilities, but this should show a concept.

    Hope this helps,

    Faris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •