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)

How VBA variable pass a value to a Report calculated field ?

(0) ShareShare
ReportReport
Posted on by 3,795

I am still a newbie of VBA. I have a modified report, under the Report Writer, I created a calculated field named as curDocAmt and then in VBA (Microsoft Visual Basic) I have some scripts and it will then assign a computed value to pass to the calculated field, curDocAmt.

But the problem is my VBA script just cannot do it job. Please check below and advise me. Thank you so much.

curDocAmt.value = varNewAmt


*This post is locked for comments

I have the same question (0)
  • sandipdjadhav Profile Picture
    18,306 on at

    VBA code will not work if your code is not in proper header i.e. in Start , or  BeforAH,BeforeBody. it depend where is your calculated field in Report.

    I face this type of problem as soon as I moved my code to proper event it started working.

    Thanks

    Sandip

  • William Kow Profile Picture
    3,795 on at

    Many thing for your reply.

    Yes, the field name in the VBA is under Report_BeforeBody event. And I put the report calculated field in the report body. What is other possibility for the VBA cannot recognize the report calculated field.

    Thank you so much.

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,095 Most Valuable Professional on at

    You need to add the report AND the field to Visual Basic.

    Highlight the field in the report layout mode and select Tools >> Customize >> Add Field to Visual Basic.

    David

    David Musgrave [MSFT]
    Escalation Engineer - Microsoft Dynamics GP
    Microsoft Dynamics Support - Asia Pacific

    Microsoft Dynamics (formerly Microsoft Business Solutions)
    http://www.microsoft.com/Dynamics

    mailto:David dot Musgrave at microsoft dot com
    http://blogs.msdn.com/DevelopingForDynamicsGP

    Any views contained within are my personal views and not necessarily Microsoft policy.
    This posting is provided "AS IS" with no warranties, and confers no rights. 

  • L Vail Profile Picture
    65,271 on at

    Does the Result Type of the calculated field match the data type you are sending it? Does any value print? Has security been granted to the modified report?

    Just a couple of thoughts.

    Kind regards,

    Leslie

  • William Kow Profile Picture
    3,795 on at

    Thank you so much David.

    I do not even aware that the report calculated "field" is also need to "add" into the VBA. All the while I thought just only need to add the "Modified Report" into the VBA -- so i have ignored the report objects/fields are also need to add into VBA -- so that it can be recognized in VBA.

    Thanks.

     

  • William Kow Profile Picture
    3,795 on at

    Many thanks for your reply. I always compile to VBA for validity before I run the report with VBA script. the error related to report field is not recognized by VBA is mainly due to my missing step to add it into VBA -- mentioned by David.

    Again, I would like to thank to all the people who contribute in this community.

     

  • L Vail Profile Picture
    65,271 on at

    Ahh David,

    Did we have the machine turnded on ; . .

    Thanks for your excellent help!;

     

    Kind regards,

     Lesllie

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,095 Most Valuable Professional on at

    I have the advantage that I am also working on the issue from a support case and have the package file.

    But I made that suggestion before looking at the package file. :-)

    David

     

    David Musgrave [MSFT]
    Escalation Engineer - Microsoft Dynamics GP
    Microsoft Dynamics Support - Asia Pacific

    Microsoft Dynamics (formerly Microsoft Business Solutions)
    http://www.microsoft.com/Dynamics

    mailto:David dot Musgrave at microsoft dot com
    http://blogs.msdn.com/DevelopingForDynamicsGP

    Any views contained within are my personal views and not necessarily Microsoft policy.
    This posting is provided "AS IS" with no warranties, and confers no rights. 

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