Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 12th, 2004, 07:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default Query/formatting problem in report

Hi.
I'm trying to make some sort of color formatting in my report, but can't get the field from my query evaluated. So far this is what I have come up with:
Code:
Private Sub Detaljesektion_Format(Cancel As Integer, FormatCount As Integer)
  Const Green = 8454016
  Const White = 16777215

  Select Case ([qrySamleaftaler].[HarAreal]) 'this is my query
    Case True
      Me.FillColor = Green
    Case False
      Me.FillColor = White
    Case Else
      Me.FillColor = White
  End Select
End Sub
I get a run-time error '2465' when I try to use it. Any help to this newbie problem would be great!

 - mega
__________________
- mega
Aspiring JavaScript Ninja
 
Old August 14th, 2004, 03:19 PM
Authorized User
 
Join Date: Oct 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Assuming qrySamleaftaler, is the datasource, for your report, to reference a control...


Instead of..
Select Case ([qrySamleaftaler].[HarAreal]) 'this is my query
try...
Select Case Me.HarAreal


Or, if your query is based on more than one table, and more than one control has the same name, you would use
Me.[tblTable.Field] (I believe, that is the proper syntax), or something similiar.

...either way, your original is incorrect.

Hope this helps.


 
Old August 18th, 2004, 09:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

Hmm.. Thank you for the reply, but I still get the same error message.
Here is my SQL:
Code:
SELECT Data.UdlejningsenhedsNr, Data.LejeaftaleNr,
 Data.Lejer, Bem.BemNavn, Data.Samleaftale,
 Data.Type, Data.HarAreal
FROM Bem RIGHT JOIN Data ON Bem.BemID=Data.Bemærkning
WHERE (((Data.Samleaftale) Is Not Null) AND ((Data.Igangværende)=False));
I thought I might declare the query first:
Code:
Private Sub Detaljesektion_Format(Cancel As Integer, FormatCount As Integer)
  Const Green = 8454016
  Const White = 16777215
  Dim blnHarAreal As Query 'trying to declare...
  blnHarAreal = Me.[qrySamleaftaler.HarAreal]
  
  Select Case (blnHarAreal) 'this is my query
    Case True
      Me.FillColor = Green
    Case False
      Me.FillColor = White
    Case Else
      Me.FillColor = White
  End Select
End Sub
That didn't work.. Do you know where I can find a good tutorial on Access VBA - report formatting?

- mega
 
Old August 18th, 2004, 07:12 PM
Authorized User
 
Join Date: Oct 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't know of one, exclusively for "report formatting".

But mega, I think you need to open a filtered report, for what you are trying to do.
(I didn't follow your objective, till now).

Something like this...


Private Sub Report_Open(Cancel As Integer)
Dim SQL As String

SQL = "SELECT Data.UdlejningsenhedsNr, Data.LejeaftaleNr, Data.Lejer, Bem.BemNavn, Data.Samleaftale, " & _
 "Data.Type, Data.HarAreal " & _
"FROM Bem RIGHT JOIN Data ON Bem.BemID=Data.Bemærkning " & _
"WHERE (((Data.Samleaftale) Is Not Null) AND ((Data.Igangværende)=False));"

Me.RecordSource = SQL
End Sub

Then...

Private Sub Detaljesektion_Format(Cancel As Integer, FormatCount As Integer)
  Const Green = 8454016
  Const White = 16777215

  Select Case HarAreal 'this should be, name of textbox (assuming, it has true/false value?)
    Case True
      Me.FillColor = Green
    Case False
      Me.FillColor = White
    Case Else
      Me.FillColor = White
  End Select
End Sub

This is one option.
I haven't used Report filter before, but this should work.
Good Luck, I'll stay posted.

 
Old September 1st, 2004, 04:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

What I really want to do is not showing HarAreal and Type, but change the background color of the detail section according to those 2 (HarAreal and Type) true/false fields. The question is how do I refer to the query on which my report is build upon?

 - mega
 
Old September 1st, 2004, 11:27 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ara_gupta Send a message via Yahoo to ara_gupta
Default

Please explain more details in ur question. I have a alternate code.
Select case()
    Case True
      RPT.FillColor = Green
    Case False
      RPT.FillColor = White
    Case Else
      RPT.FillColor = White
  End Select


aranibhash
 
Old September 1st, 2004, 11:40 PM
Authorized User
 
Join Date: Oct 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Niet te Geloven!, Ik ben stom, denke ik?

Me.Detail.BackColor = vbGreen

Heel makelijk!

 
Old September 1st, 2004, 11:52 PM
Authorized User
 
Join Date: Oct 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Probeer deze....

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)


  Select Case HarAreal
    Case True
      Me.Detail.BackColor = vbGreen

        Case Else
      Me.Detail.BackColor = vbWhite

  End Select
End Sub


 
Old September 16th, 2004, 04:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

Tanks for the replies.
I got my report up and working based on a stored procedure (RecordSource = qrySamleaftaler).
In the stored proc I get all the fields I want, filtered and joint. It's only the presentation of the data that's troubling me. Right now I've made some extra fields in the report (Data.Type, Data.HarAreal), I don't want to display those as fields but as different bgcolors. I figured if I could get just one the fields working, I could easily make my formatting from there. But right now I can not figure out how to accomplish this.

Cheers.

 - mega





Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting Query rsm42 ASP.NET 1.0 and 1.1 Basics 1 May 19th, 2007 04:58 AM
Formatting Query rsm42 ASP.NET 1.0 and 1.1 Basics 0 December 21st, 2006 02:47 PM
Report Formatting echovue Access 3 October 10th, 2006 01:48 PM
problem with formatting the crystal report tallapaneni Crystal Reports 1 May 24th, 2005 01:38 PM
Report Formatting John Anthony Access VBA 3 October 15th, 2003 11:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.