Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Grouping VBA Code Question

Status
Not open for further replies.

Quintios

Technical User
Mar 7, 2002
482
US
I have a report that groups things by, say, numerical month. So when the report prints there's the top group bar that says 'Month' and has it's information, and then below that there's the Detail section.

Is there a way to extract the number of the month that the report is grouping on in VBA? Reason I ask is because I want to use the month number in an SQL statement.

Thanks in advance,

Onwards,

Q-
 
Your question prompts the response:-

Dim intMonth As Integer
intMonth = Month(DateValue)

But I can't help thinking that I'm on the wrong track ( If I am I appologise - can you clarify what you mean ? )


G LS
 
Weeellll, actually I'm not dealing with dates. I just used that as an example to clarify what I'm doing.

What I'm dealing with are groups of programming variables. The database is used to design strategy for controlling chemical plants. Each variable falls into a "Sequence" (which is the 'month' in the first example I described).

So when I print preview a list of the variables sorted by "Sequence" number, how can I obtain the numerical value of the field "Sequence" that is currently being formatted?
Onwards,

Q-
 
Arrrh so do you mean

Code:
SequenceNumber     ActualValueSortedOn
     1                      1
     2                      3
     3                      4
     4                      7
     5                      8
     6                      9
etc .. ..

In that you have the values in the second column that you are 'grouping and sorting on' yet this list might contain gaps in the integer series ( & not even start at 1 possibly ) but you want to be able to disply the first column.

Is that it ?


G LS
 
Yeah. But it gets worse. The report will appear something like this:

Code:
SequenceID 12 (Grouped by this)

TagID             Step  (data I want to display)
------------------------
TAG1              STEP1
TAG1              STEP2
TAG1              STEP3
TAG2              STEP1
TAG2              STEP2
TAG2              STEP3

Sequence 16

TagID             Step  (data I want to display)
------------------------
TAG1              STEP1
TAG1              STEP2
TAG1              STEP3
TAG1              STEP4
TAG2              STEP1
TAG2              STEP2
TAG2              STEP3
TAG2              STEP4

So what you see above is basically the way the report goes. What I'd like to do is insert a space between when the TagID changes to make the report more legible. So I figure if I can get the sequence number, I can pull a recordset for the number of Steps in that sequence with the .recordcount and then change the variable that counts when to skip a line.

So, how do I pull out the actual value of the sort of a header? I found a way to get the source, use the code Me.GroupHeader(0).ControlSource, but I don't see a way to get the value...
Onwards,

Q-
 
How about a TOTALLY different approach ?

Globally Dim strOldTag As Sting


In the Detail Section OnPrint event
Code:
If ControlHoldingTagValue = "Tag" then 
    strOldTag = ControlHoldingTagValue 
Else
    If ControlHoldingTagValue = strOldTag Then
        ' Do Nothing
    Else
        Expand the size of a dummycontrol at the top of the detail section to force a space
        ( OR LineControl.Visible = True )
        strOldTag = ControlHoldingTagValue 
    End If
End If


Any Help ?
G LS



set a global variable to the value of the field holding the tag number.

 
I'm not sure I follow your code... I'm not that good at this yet I think. I need to get the number of steps per sequence, and then when sequence X comes up I need to skip every y records, where y is the number of steps that are in that sequence.

Clear as mud?

What's the difference between the detail_format and the onprint events? Why wouldn't I put the code in the detail_format so I could print preview it? Or is that not the case?
Onwards,

Q-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top