Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

VBA calling cashbook report passing in restriction

(0) ShareShare
ReportReport
Posted on by 196

I am following Mr David's post: VBA – Calling a Report using Visual Basic for Applications, to call a cashbook management report CB_Payments_Report and to pass in a restriction, using VBA as follow:

Commands = Commands & " with restriction 'Check Number' of table CB_Payments_Report = "my check number" 

but is receiving error unknown identifier CB_Payments_Report

it seems that it is not able to reference to table CB_Payments_Report

any help will be much appreciated.

thanks in advance.

Categories:
  • Verified answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,965 Most Valuable Professional on at
    RE: VBA calling cashbook report passing in restriction

    Hi Lo

    For reference, the blog article being used is below:

    https://winthropdc.wordpress.com/2010/04/13/vba-calling-a-report-using-visual-basic-for-applications/

    As this is passthrough sanScript built from VBA, you need to make sure that you double up the double quotes when passing through strings. If also wanting terminate the VBA string to add in a field from a window you will need to triple up the quotes. 

    See example below

    Commands = Commands & "run report with name ""Custom Report Name Here"" " & vbCrLf
    Commands = Commands & " with restriction 'Check Number' of table CB_Payments_Report = """ & CheckNumber & """ " & vbCrLf

    You are correct that you will also need to change the " in dictionary 0; " part to have the correct dictionary number to ensure that the report is found.  I would also suggest uncommenting the line below and changing the dictionary number so that script is compiled in the context of the cash book dictionary and the references to the CB_ tables don't fail to compile.

    'CompilerApp.CurrentProductID = 0 ' 0 = Dynamics
    Kind regards
    David
  • HFLo Profile Picture
    HFLo 196 on at
    RE: VBA calling cashbook report passing in restriction

    BTW, (again, base on Mr David's post), I have used cashbook dictionary ID as follow:

    Commands = Commands & "  in dictionary 1058; " 

    and it does print CB_Payments_Report if I don't pass in any restriction.

    so, I am quite sure the error is caused by the restriction line as stated in my original post.

     

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,492 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans