944,082 Members | Top Members by Rank

Ad:
Jun 6th, 2006
0

Change Access Title in VB6

Expand Post »
I am desparate, please can someone tell me how I can change a report title in an Access 2000 report from within my VB6 code?

I did something like this but it is not changing thye title

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Sub PrintReport(TheReport As String, TheCriteria As String, TheHeading As String)
  2. '------------------------- If access is open then close it --------------
  3. On Error Resume Next
  4. objAccess.Quit
  5. On Error GoTo NoRecords
  6. '------------------------- Open Database --------------------------------
  7. Set objAccess = New Access.Application
  8. objAccess.Visible = True
  9. objAccess.OpenCurrentDatabase (DatabasePath)
  10. objAccess.RunCommand acCmdAppMaximize
  11. '------------------------- Open Report and set the Heading --------------
  12. objAccess.DoCmd.OpenReport TheReport, acViewPreview, , TheCriteria
  13. If TheHeading <> "" Then
  14. objAccess.Reports(TheReport).Controls!lblHeading.Caption = TheHeading
  15. End If
  16. '------------------------- Set the criteria for report ------------------
  17. If TheCriteria <> "" Then
  18. objAccess.Reports(TheReport).Filter = TheCriteria
  19. DoEvents
  20. End If
  21. objAccess.Reports(TheReport).FilterOn = True
  22. DoEvents
  23. objAccess.DoCmd.Maximize
  24. objAccess.Visible = True
  25. Exit Sub
  26. NoRecords:
  27. If Err.Number = 2486 Then
  28. Resume
  29. Else
  30. MsgBox "There are no records that match your request.", vbExclamation, "No Records"
  31. End If
  32. End Sub
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
llabelle is offline Offline
1 posts
since Jun 2006
Jun 9th, 2006
0

Re: Change Access Title in VB6

I'm sure it's just something simple, like maybe try refreshing the report after you set the label value? If your really desperate, create a table linked to the table which your report is pulling from to hold different title values and update the table prior to calling your report. Base your report off a query which then pulls your original data plus the newly updated title from the related table.
Reputation Points: 37
Solved Threads: 18
Junior Poster
agrothe is offline Offline
151 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: coding IM: notifiyng clients of others online presence
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Value Compare





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC