Skip to main content

Notifications

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 202

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
    14,036 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
    202 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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 601 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 416

#3
Adis Profile Picture

Adis 384 Super User 2025 Season 1

Product updates

Dynamics 365 release plans