web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

VBA parameter cause problem to SQL Stored Procedure

(0) ShareShare
ReportReport
Posted on by 3,795

I need to prepare a different set of records for Report Writer to printout.

I can find a few sample of how to use VBA and I managed to retrieve SQL tables and pass to recordset, However, I do not managed to find VBA samples on how to do define parameters for SQL stored procedure, especially for date field.

Please find the attached is my VBA coding and I wish to get return into recordset returned from a Stored Procedure with parameter (date field).

http://img806.imageshack.us/img806/9209/20100719083552.png

In the VBA, I unable to get the receordset correct. Please advise.

Can you please provide me more samples & examples for VBA call Stored Procedure with parameter, return with recordset.

Thank you so much.

*This post is locked for comments

I have the same question (0)
  • L Vail Profile Picture
    65,271 on at

    Hi William,

    I'm not sure this will help, but it has been my experience that GP is picky about date format. If I use 2014-01-01 00:00:00.000, I have good luck with it.

    Kind regards,

    Leslie

  • MG-16101311-0 Profile Picture
    26,225 on at

    Remember that SQL Server expects dates to be enclosed in single quotes. Try this for your code (note I also removed the @ sign from the parameter name):

    set param1 = .CreateParameter("agingDate", adDate, adParamInput,, "'" & FormatDateTime(Date, 1) & "'")

    If your stored procedure returns one and only one record, you may want to consider using an out parameter (or several as you see fit) for retrieving the columns that you need to retrieve, instead of using a recordset.

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans