Change Access Title in VB6

Reply

Join Date: Jun 2006
Posts: 1
Reputation: llabelle is an unknown quantity at this point 
Solved Threads: 0
llabelle llabelle is offline Offline
Newbie Poster

Change Access Title in VB6

 
0
  #1
Jun 6th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 119
Reputation: agrothe is an unknown quantity at this point 
Solved Threads: 14
agrothe's Avatar
agrothe agrothe is offline Offline
Junior Poster

Re: Change Access Title in VB6

 
0
  #2
Jun 9th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC