Need example of VBA code in Report writer
*This post is locked for comments
Need example of VBA code in Report writer
*This post is locked for comments
Thank you very much Soma. THAT WORKED PERFECT.
Write your code for both before Page Header & Report Header only.
Hope this helps!!!
Thanks for the responses but I have already tried all of that. This is my code:
Dim rst As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim sqlstring As String
sqlstring = "SELECT crdtmgr from cn00500 where CUSTNMBR = '" & CustomerNumber & "'"
' ADO Command
cmd.ActiveConnection = cn
' adCmdText
cmd.CommandType = 1
' Command
cmd.CommandText = sqlstring
' Pass through SQL
Set rst = cmd.Execute
sqlstring = "select CollectorName, CN_Collector_Phone1 from DYNAMICS..CN01400 where CollectorID = '" & strcrdtmgr & "'"
' ADO Command
cmd.ActiveConnection = cn
' adCmdText
cmd.CommandType = 1
' Command
cmd.CommandText = sqlstring
Set rst = cmd.Execute
If Not (rst.EOF And rst.BOF) Then
CollectorName1.Value = rst!CollectorName
CollectorPhone.Value = rst!CN_Collector_Phone1
End If
rst.Close
Set rst = Nothing
Set cmd = Nothing
I am trying to print the Collectoname1 and CollectorPhone on the Customer Statement header which is where the customer number prints. Do I still put my code in the Before Body? That does not work!! HELP
Hi DHC,
Please find the below link that will guide you to develop a report using Modifier with VBA.
Also have a look on the below link for ADO connection with VBA and Report Writer.
blogs.msdn.com/.../using-ado-with-vba-with-report-writer.aspx
Hope this helps!!!
Hi DHC,
The below link should help you. Its a well detailed article by David Musgrave on using VBA with Report writer.
blogs.msdn.com/.../using-vba-with-report-writer.aspx
Hope this helps.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156