creating "map" based on field values

O

okschlaps

I have a report I would like to convert into a kind of map. I'm trying to do
this by creating labels that correspond to particular sections. If acreage in
a section meets certain criteria, the label would be colored accordingly. The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code I'm using for
an event procedure under the format event for the group footer for each STR
(made up of 36 sections.) But all my "maps" look the same and do not reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other" And Me.PCT > 0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT > 0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail section of the
report. It didn't matter if I moved the map to the detail section - it was
still inaccurate.
Should I simply set up a function in a query to create a new field
representing the section status? Also, there are 36 sections and I would
really like to simplify the code - I assume there's an easy way with an
array. Could you point me in the right direction on that, too.
Thanks
 
S

Steve

In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a series of 36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
D

Duane Hookom

As Steve suggested, you might be able to change all your code to something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand something doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


Steve said:
In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a series of 36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)



okschlaps said:
I have a report I would like to convert into a kind of map. I'm trying to
do
this by creating labels that correspond to particular sections. If acreage
in
a section meets certain criteria, the label would be colored accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code I'm using for
an event procedure under the format event for the group footer for each
STR
(made up of 36 sections.) But all my "maps" look the same and do not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other" And Me.PCT >
0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT >
0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail section of
the
report. It didn't matter if I moved the map to the detail section - it was
still inaccurate.
Should I simply set up a function in a query to create a new field
representing the section status? Also, there are 36 sections and I would
really like to simplify the code - I assume there's an easy way with an
array. Could you point me in the right direction on that, too.
Thanks

 
O

okschlaps

Perfect! That code is much prettier. Plus, I don't know why, but it's making
my maps work. Before each map returned the same incorrect data, but now they
are accurate.
Thanks for your help!

Duane Hookom said:
As Steve suggested, you might be able to change all your code to something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand something doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


Steve said:
In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a series of 36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)



okschlaps said:
I have a report I would like to convert into a kind of map. I'm trying to
do
this by creating labels that correspond to particular sections. If acreage
in
a section meets certain criteria, the label would be colored accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code I'm using for
an event procedure under the format event for the group footer for each
STR
(made up of 36 sections.) But all my "maps" look the same and do not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other" And Me.PCT >
0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT >
0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail section of
the
report. It didn't matter if I moved the map to the detail section - it was
still inaccurate.
Should I simply set up a function in a query to create a new field
representing the section status? Also, there are 36 sections and I would
really like to simplify the code - I assume there's an easy way with an
array. Could you point me in the right direction on that, too.
Thanks

 
O

okschlaps

I spoke too soon. The code runs, but only the last label is colored in. For
instance, in one group, there are three sections that meet the criteria, but
only the last is colored in. Are all labels reformatted according to the last
"for" in the loop?

Duane Hookom said:
As Steve suggested, you might be able to change all your code to something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand something doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


Steve said:
In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a series of 36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)



okschlaps said:
I have a report I would like to convert into a kind of map. I'm trying to
do
this by creating labels that correspond to particular sections. If acreage
in
a section meets certain criteria, the label would be colored accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code I'm using for
an event procedure under the format event for the group footer for each
STR
(made up of 36 sections.) But all my "maps" look the same and do not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other" And Me.PCT >
0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT >
0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail section of
the
report. It didn't matter if I moved the map to the detail section - it was
still inaccurate.
Should I simply set up a function in a query to create a new field
representing the section status? Also, there are 36 sections and I would
really like to simplify the code - I assume there's an easy way with an
array. Could you point me in the right direction on that, too.
Thanks

 
S

Steve

Here is the second If loop in your original post --
If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT > 0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

Note in the If and ElseIf statements you try to change the BackColor of L1
but in the Else statement you try and change the BackColor of L2. I asked
you in my post about this. Duane's code differs from your code in that his
code looks at the properties of Section 02 and for ALL conditions tries to
change the BackColor of L2.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





okschlaps said:
I spoke too soon. The code runs, but only the last label is colored in. For
instance, in one group, there are three sections that meet the criteria,
but
only the last is colored in. Are all labels reformatted according to the
last
"for" in the loop?

Duane Hookom said:
As Steve suggested, you might be able to change all your code to
something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And Me.PCT >
0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand something
doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


Steve said:
In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a series of
36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)



I have a report I would like to convert into a kind of map. I'm trying
to
do
this by creating labels that correspond to particular sections. If
acreage
in
a section meets certain criteria, the label would be colored
accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code I'm
using for
an event procedure under the format event for the group footer for
each
STR
(made up of 36 sections.) But all my "maps" look the same and do not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other" And Me.PCT

0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail section
of
the
report. It didn't matter if I moved the map to the detail section -
it was
still inaccurate.
Should I simply set up a function in a query to create a new field
representing the section status? Also, there are 36 sections and I
would
really like to simplify the code - I assume there's an easy way with
an
array. Could you point me in the right direction on that, too.
Thanks
 
D

Duane Hookom

As per my previous post: "It isn't clear what your records look like. We
understand something doesn't work but we don't know much more."

Apparently your code is in a group section while the controls are in
another. I would expect the issues you are experiencing. If we knew your
structure and what you wanted to accomplish, we might be able to provide some
assistance.

--
Duane Hookom
Microsoft Access MVP


okschlaps said:
I spoke too soon. The code runs, but only the last label is colored in. For
instance, in one group, there are three sections that meet the criteria, but
only the last is colored in. Are all labels reformatted according to the last
"for" in the loop?

Duane Hookom said:
As Steve suggested, you might be able to change all your code to something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand something doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


Steve said:
In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a series of 36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)



I have a report I would like to convert into a kind of map. I'm trying to
do
this by creating labels that correspond to particular sections. If acreage
in
a section meets certain criteria, the label would be colored accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code I'm using for
an event procedure under the format event for the group footer for each
STR
(made up of 36 sections.) But all my "maps" look the same and do not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other" And Me.PCT >
0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT >
0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail section of
the
report. It didn't matter if I moved the map to the detail section - it was
still inaccurate.
Should I simply set up a function in a query to create a new field
representing the section status? Also, there are 36 sections and I would
really like to simplify the code - I assume there's an easy way with an
array. Could you point me in the right direction on that, too.
Thanks
 
O

okschlaps

Steve
Yeah, Duane was right, the code should have been for L2 in the second loop
(then L3 in the third, etc.) Each Label corresponds to a Section. I have them
laid out in a grid (it all has to do with land work.)
I suspect Duane is right, that because my data are in the detail section and
the "map" (labels) are in the group footer, it's not processing correctly. I
tried to do a print screen of my report, but can't paste it in here.
I'll try to clarify. There are 36 sections. I need each section represented
on a map, or grid and am using color to indicate the status of that
particular section according to the criteria specified in the code.
So the map looks something like
6 5 4 3 2 1
7 8 9 10 11 12
18 17 16 15 14 13
etc
Each number would be in a label and I'm trying to color these.
Hope that helps and I really appreciate your efforts!

Steve said:
Here is the second If loop in your original post --
If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT > 0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

Note in the If and ElseIf statements you try to change the BackColor of L1
but in the Else statement you try and change the BackColor of L2. I asked
you in my post about this. Duane's code differs from your code in that his
code looks at the properties of Section 02 and for ALL conditions tries to
change the BackColor of L2.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





okschlaps said:
I spoke too soon. The code runs, but only the last label is colored in. For
instance, in one group, there are three sections that meet the criteria,
but
only the last is colored in. Are all labels reformatted according to the
last
"for" in the loop?

Duane Hookom said:
As Steve suggested, you might be able to change all your code to
something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And Me.PCT >
0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand something
doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


:

In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a series of
36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)



I have a report I would like to convert into a kind of map. I'm trying
to
do
this by creating labels that correspond to particular sections. If
acreage
in
a section meets certain criteria, the label would be colored
accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code I'm
using for
an event procedure under the format event for the group footer for
each
STR
(made up of 36 sections.) But all my "maps" look the same and do not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other" And Me.PCT

0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail section
of
the
report. It didn't matter if I moved the map to the detail section -
it was
still inaccurate.
Should I simply set up a function in a query to create a new field
representing the section status? Also, there are 36 sections and I
would
really like to simplify the code - I assume there's an easy way with
an
array. Could you point me in the right direction on that, too.
Thanks

 
S

Steve

Let's try this ---

Make a copy of your report and let's make some changes. First, make the
recordsource property blank. Remove all textboxes that show data. Move your
map labels into the detail section. Make sure your labels are named L1 to
L36 and the captions are 1 to 36. Now I am going to assume you have a table
named TblLandSection that records the data for the 36 sections and the
fields are Section, Status and Percent. I am assuming all sections are
numbered from 1 to 36. Create a query based on TblLand Section named
QryLandSection and sort ascending on Section.

Put the following code in the report's Open event:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
For intS = 1 to 36
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




okschlaps said:
Steve
Yeah, Duane was right, the code should have been for L2 in the second loop
(then L3 in the third, etc.) Each Label corresponds to a Section. I have
them
laid out in a grid (it all has to do with land work.)
I suspect Duane is right, that because my data are in the detail section
and
the "map" (labels) are in the group footer, it's not processing correctly.
I
tried to do a print screen of my report, but can't paste it in here.
I'll try to clarify. There are 36 sections. I need each section
represented
on a map, or grid and am using color to indicate the status of that
particular section according to the criteria specified in the code.
So the map looks something like
6 5 4 3 2 1
7 8 9 10 11 12
18 17 16 15 14 13
etc
Each number would be in a label and I'm trying to color these.
Hope that helps and I really appreciate your efforts!

Steve said:
Here is the second If loop in your original post --
If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT >
0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

Note in the If and ElseIf statements you try to change the BackColor of
L1
but in the Else statement you try and change the BackColor of L2. I asked
you in my post about this. Duane's code differs from your code in that
his
code looks at the properties of Section 02 and for ALL conditions tries
to
change the BackColor of L2.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





okschlaps said:
I spoke too soon. The code runs, but only the last label is colored in.
For
instance, in one group, there are three sections that meet the
criteria,
but
only the last is colored in. Are all labels reformatted according to
the
last
"for" in the loop?

:

As Steve suggested, you might be able to change all your code to
something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And Me.PCT

0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand something
doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


:

In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a series
of
36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)



I have a report I would like to convert into a kind of map. I'm
trying
to
do
this by creating labels that correspond to particular sections. If
acreage
in
a section meets certain criteria, the label would be colored
accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code I'm
using for
an event procedure under the format event for the group footer for
each
STR
(made up of 36 sections.) But all my "maps" look the same and do
not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other" And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail
section
of
the
report. It didn't matter if I moved the map to the detail
section -
it was
still inaccurate.
Should I simply set up a function in a query to create a new field
representing the section status? Also, there are 36 sections and I
would
really like to simplify the code - I assume there's an easy way
with
an
array. Could you point me in the right direction on that, too.
Thanks

 
O

okschlaps

Steve
It ran, but all the labels came out blue.

Steve said:
Let's try this ---

Make a copy of your report and let's make some changes. First, make the
recordsource property blank. Remove all textboxes that show data. Move your
map labels into the detail section. Make sure your labels are named L1 to
L36 and the captions are 1 to 36. Now I am going to assume you have a table
named TblLandSection that records the data for the 36 sections and the
fields are Section, Status and Percent. I am assuming all sections are
numbered from 1 to 36. Create a query based on TblLand Section named
QryLandSection and sort ascending on Section.

Put the following code in the report's Open event:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
For intS = 1 to 36
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




okschlaps said:
Steve
Yeah, Duane was right, the code should have been for L2 in the second loop
(then L3 in the third, etc.) Each Label corresponds to a Section. I have
them
laid out in a grid (it all has to do with land work.)
I suspect Duane is right, that because my data are in the detail section
and
the "map" (labels) are in the group footer, it's not processing correctly.
I
tried to do a print screen of my report, but can't paste it in here.
I'll try to clarify. There are 36 sections. I need each section
represented
on a map, or grid and am using color to indicate the status of that
particular section according to the criteria specified in the code.
So the map looks something like
6 5 4 3 2 1
7 8 9 10 11 12
18 17 16 15 14 13
etc
Each number would be in a label and I'm trying to color these.
Hope that helps and I really appreciate your efforts!

Steve said:
Here is the second If loop in your original post --
If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT >
0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

Note in the If and ElseIf statements you try to change the BackColor of
L1
but in the Else statement you try and change the BackColor of L2. I asked
you in my post about this. Duane's code differs from your code in that
his
code looks at the properties of Section 02 and for ALL conditions tries
to
change the BackColor of L2.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





I spoke too soon. The code runs, but only the last label is colored in.
For
instance, in one group, there are three sections that meet the
criteria,
but
only the last is colored in. Are all labels reformatted according to
the
last
"for" in the loop?

:

As Steve suggested, you might be able to change all your code to
something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And Me.PCT

0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand something
doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


:

In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a series
of
36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)



I have a report I would like to convert into a kind of map. I'm
trying
to
do
this by creating labels that correspond to particular sections. If
acreage
in
a section meets certain criteria, the label would be colored
accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code I'm
using for
an event procedure under the format event for the group footer for
each
STR
(made up of 36 sections.) But all my "maps" look the same and do
not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other" And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail
section
of
the
report. It didn't matter if I moved the map to the detail
section -
it was
still inaccurate.
Should I simply set up a function in a query to create a new field
representing the section status? Also, there are 36 sections and I
would
really like to simplify the code - I assume there's an easy way
with
an
array. Could you point me in the right direction on that, too.
Thanks

 
S

Steve

I copied Duane's code and modified it but neglected to make one change.
Change the code to this:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
intS = 0
Do Until Rst.EOF
intS = intS + 1
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Rst.Next
Loop
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





okschlaps said:
Steve
It ran, but all the labels came out blue.

Steve said:
Let's try this ---

Make a copy of your report and let's make some changes. First, make the
recordsource property blank. Remove all textboxes that show data. Move
your
map labels into the detail section. Make sure your labels are named L1 to
L36 and the captions are 1 to 36. Now I am going to assume you have a
table
named TblLandSection that records the data for the 36 sections and the
fields are Section, Status and Percent. I am assuming all sections are
numbered from 1 to 36. Create a query based on TblLand Section named
QryLandSection and sort ascending on Section.

Put the following code in the report's Open event:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
For intS = 1 to 36
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




okschlaps said:
Steve
Yeah, Duane was right, the code should have been for L2 in the second
loop
(then L3 in the third, etc.) Each Label corresponds to a Section. I
have
them
laid out in a grid (it all has to do with land work.)
I suspect Duane is right, that because my data are in the detail
section
and
the "map" (labels) are in the group footer, it's not processing
correctly.
I
tried to do a print screen of my report, but can't paste it in here.
I'll try to clarify. There are 36 sections. I need each section
represented
on a map, or grid and am using color to indicate the status of that
particular section according to the criteria specified in the code.
So the map looks something like
6 5 4 3 2 1
7 8 9 10 11 12
18 17 16 15 14 13
etc
Each number would be in a label and I'm trying to color these.
Hope that helps and I really appreciate your efforts!

:

Here is the second If loop in your original post --
If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

Note in the If and ElseIf statements you try to change the BackColor
of
L1
but in the Else statement you try and change the BackColor of L2. I
asked
you in my post about this. Duane's code differs from your code in that
his
code looks at the properties of Section 02 and for ALL conditions
tries
to
change the BackColor of L2.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





I spoke too soon. The code runs, but only the last label is colored
in.
For
instance, in one group, there are three sections that meet the
criteria,
but
only the last is colored in. Are all labels reformatted according to
the
last
"for" in the loop?

:

As Steve suggested, you might be able to change all your code to
something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And
Me.PCT

0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand something
doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


:

In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a
series
of
36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And
Word
Applications
(e-mail address removed)



message
I have a report I would like to convert into a kind of map. I'm
trying
to
do
this by creating labels that correspond to particular sections.
If
acreage
in
a section meets certain criteria, the label would be colored
accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code
I'm
using for
an event procedure under the format event for the group footer
for
each
STR
(made up of 36 sections.) But all my "maps" look the same and
do
not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other" And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT >
0.75
Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail
section
of
the
report. It didn't matter if I moved the map to the detail
section -
it was
still inaccurate.
Should I simply set up a function in a query to create a new
field
representing the section status? Also, there are 36 sections
and I
would
really like to simplify the code - I assume there's an easy way
with
an
array. Could you point me in the right direction on that, too.
Thanks

 
O

okschlaps

I'm getting a "Method or data member not found" error at Rst.Next. I've
copied my code in case I've typed something wrong. Thanks
Private Sub Report_Open(Cancel As Integer)
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS As Integer
Dim strS As String
Set Db = CurrentDb
Set Rst = Db.OpenRecordset("qryLANDSECTION")
intS = 0
Do Until Rst.EOF
intS = intS + 1
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Rst.Next
Loop
Rst.Close
Set Rst = Nothing
Set Db = Nothing

End Sub

Steve said:
I copied Duane's code and modified it but neglected to make one change.
Change the code to this:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
intS = 0
Do Until Rst.EOF
intS = intS + 1
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Rst.Next
Loop
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





okschlaps said:
Steve
It ran, but all the labels came out blue.

Steve said:
Let's try this ---

Make a copy of your report and let's make some changes. First, make the
recordsource property blank. Remove all textboxes that show data. Move
your
map labels into the detail section. Make sure your labels are named L1 to
L36 and the captions are 1 to 36. Now I am going to assume you have a
table
named TblLandSection that records the data for the 36 sections and the
fields are Section, Status and Percent. I am assuming all sections are
numbered from 1 to 36. Create a query based on TblLand Section named
QryLandSection and sort ascending on Section.

Put the following code in the report's Open event:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
For intS = 1 to 36
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




Steve
Yeah, Duane was right, the code should have been for L2 in the second
loop
(then L3 in the third, etc.) Each Label corresponds to a Section. I
have
them
laid out in a grid (it all has to do with land work.)
I suspect Duane is right, that because my data are in the detail
section
and
the "map" (labels) are in the group footer, it's not processing
correctly.
I
tried to do a print screen of my report, but can't paste it in here.
I'll try to clarify. There are 36 sections. I need each section
represented
on a map, or grid and am using color to indicate the status of that
particular section according to the criteria specified in the code.
So the map looks something like
6 5 4 3 2 1
7 8 9 10 11 12
18 17 16 15 14 13
etc
Each number would be in a label and I'm trying to color these.
Hope that helps and I really appreciate your efforts!

:

Here is the second If loop in your original post --
If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

Note in the If and ElseIf statements you try to change the BackColor
of
L1
but in the Else statement you try and change the BackColor of L2. I
asked
you in my post about this. Duane's code differs from your code in that
his
code looks at the properties of Section 02 and for ALL conditions
tries
to
change the BackColor of L2.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





I spoke too soon. The code runs, but only the last label is colored
in.
For
instance, in one group, there are three sections that meet the
criteria,
but
only the last is colored in. Are all labels reformatted according to
the
last
"for" in the loop?

:

As Steve suggested, you might be able to change all your code to
something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And
Me.PCT

0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand something
doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


:

In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a
series
of
36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And
Word
Applications
(e-mail address removed)



message
I have a report I would like to convert into a kind of map. I'm
trying
to
do
this by creating labels that correspond to particular sections.
If
acreage
in
a section meets certain criteria, the label would be colored
accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code
I'm
using for
an event procedure under the format event for the group footer
for
each
STR
(made up of 36 sections.) But all my "maps" look the same and
do
not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other" And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT >
0.75
Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail
section
of
the
report. It didn't matter if I moved the map to the detail
section -
it was
still inaccurate.
Should I simply set up a function in a query to create a new
field
representing the section status? Also, there are 36 sections
and I
would
really like to simplify the code - I assume there's an easy way
with
an
array. Could you point me in the right direction on that, too.
Thanks

 
S

Steve

Sorry, my brain was running faster than my typing. Rst.Next should be
Rst.MoveNext.

Steve



okschlaps said:
I'm getting a "Method or data member not found" error at Rst.Next. I've
copied my code in case I've typed something wrong. Thanks
Private Sub Report_Open(Cancel As Integer)
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS As Integer
Dim strS As String
Set Db = CurrentDb
Set Rst = Db.OpenRecordset("qryLANDSECTION")
intS = 0
Do Until Rst.EOF
intS = intS + 1
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Rst.Next
Loop
Rst.Close
Set Rst = Nothing
Set Db = Nothing

End Sub

Steve said:
I copied Duane's code and modified it but neglected to make one change.
Change the code to this:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
intS = 0
Do Until Rst.EOF
intS = intS + 1
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Rst.Next
Loop
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





okschlaps said:
Steve
It ran, but all the labels came out blue.

:

Let's try this ---

Make a copy of your report and let's make some changes. First, make
the
recordsource property blank. Remove all textboxes that show data. Move
your
map labels into the detail section. Make sure your labels are named L1
to
L36 and the captions are 1 to 36. Now I am going to assume you have a
table
named TblLandSection that records the data for the 36 sections and the
fields are Section, Status and Percent. I am assuming all sections are
numbered from 1 to 36. Create a query based on TblLand Section named
QryLandSection and sort ascending on Section.

Put the following code in the report's Open event:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
For intS = 1 to 36
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




Steve
Yeah, Duane was right, the code should have been for L2 in the
second
loop
(then L3 in the third, etc.) Each Label corresponds to a Section. I
have
them
laid out in a grid (it all has to do with land work.)
I suspect Duane is right, that because my data are in the detail
section
and
the "map" (labels) are in the group footer, it's not processing
correctly.
I
tried to do a print screen of my report, but can't paste it in here.
I'll try to clarify. There are 36 sections. I need each section
represented
on a map, or grid and am using color to indicate the status of that
particular section according to the criteria specified in the code.
So the map looks something like
6 5 4 3 2 1
7 8 9 10 11 12
18 17 16 15 14 13
etc
Each number would be in a label and I'm trying to color these.
Hope that helps and I really appreciate your efforts!

:

Here is the second If loop in your original post --
If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

Note in the If and ElseIf statements you try to change the
BackColor
of
L1
but in the Else statement you try and change the BackColor of L2. I
asked
you in my post about this. Duane's code differs from your code in
that
his
code looks at the properties of Section 02 and for ALL conditions
tries
to
change the BackColor of L2.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





I spoke too soon. The code runs, but only the last label is
colored
in.
For
instance, in one group, there are three sections that meet the
criteria,
but
only the last is colored in. Are all labels reformatted according
to
the
last
"for" in the loop?

:

As Steve suggested, you might be able to change all your code to
something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And
Me.PCT

0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand
something
doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


:

In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a
series
of
36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And
Word
Applications
(e-mail address removed)



message
I have a report I would like to convert into a kind of map.
I'm
trying
to
do
this by creating labels that correspond to particular
sections.
If
acreage
in
a section meets certain criteria, the label would be colored
accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code
I'm
using for
an event procedure under the format event for the group
footer
for
each
STR
(made up of 36 sections.) But all my "maps" look the same
and
do
not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other"
And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT >
0.75
Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other"
And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

S (section), status and percent are all fields in the detail
section
of
the
report. It didn't matter if I moved the map to the detail
section -
it was
still inaccurate.
Should I simply set up a function in a query to create a new
field
representing the section status? Also, there are 36 sections
and I
would
really like to simplify the code - I assume there's an easy
way
with
an
array. Could you point me in the right direction on that,
too.
Thanks

 
O

okschlaps

Hello - I'm back. Pulled away on another project.
I'm getting an error at the "Else" line - "Can't find the field 'L37'" I
tried changing the Do until S = 35 or Do While S <36 but that didn't work
either.
Also, should I have an added criteria to relate the Label to the Section? Or
am I not understanding recordsets? Does it automatically look at one line at
a time?
Thanks again!

Steve said:
Sorry, my brain was running faster than my typing. Rst.Next should be
Rst.MoveNext.

Steve



okschlaps said:
I'm getting a "Method or data member not found" error at Rst.Next. I've
copied my code in case I've typed something wrong. Thanks
Private Sub Report_Open(Cancel As Integer)
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS As Integer
Dim strS As String
Set Db = CurrentDb
Set Rst = Db.OpenRecordset("qryLANDSECTION")
intS = 0
Do Until Rst.EOF
intS = intS + 1
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Rst.Next
Loop
Rst.Close
Set Rst = Nothing
Set Db = Nothing

End Sub

Steve said:
I copied Duane's code and modified it but neglected to make one change.
Change the code to this:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
intS = 0
Do Until Rst.EOF
intS = intS + 1
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Rst.Next
Loop
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Steve
It ran, but all the labels came out blue.

:

Let's try this ---

Make a copy of your report and let's make some changes. First, make
the
recordsource property blank. Remove all textboxes that show data. Move
your
map labels into the detail section. Make sure your labels are named L1
to
L36 and the captions are 1 to 36. Now I am going to assume you have a
table
named TblLandSection that records the data for the 36 sections and the
fields are Section, Status and Percent. I am assuming all sections are
numbered from 1 to 36. Create a query based on TblLand Section named
QryLandSection and sort ascending on Section.

Put the following code in the report's Open event:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
For intS = 1 to 36
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




Steve
Yeah, Duane was right, the code should have been for L2 in the
second
loop
(then L3 in the third, etc.) Each Label corresponds to a Section. I
have
them
laid out in a grid (it all has to do with land work.)
I suspect Duane is right, that because my data are in the detail
section
and
the "map" (labels) are in the group footer, it's not processing
correctly.
I
tried to do a print screen of my report, but can't paste it in here.
I'll try to clarify. There are 36 sections. I need each section
represented
on a map, or grid and am using color to indicate the status of that
particular section according to the criteria specified in the code.
So the map looks something like
6 5 4 3 2 1
7 8 9 10 11 12
18 17 16 15 14 13
etc
Each number would be in a label and I'm trying to color these.
Hope that helps and I really appreciate your efforts!

:

Here is the second If loop in your original post --
If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

Note in the If and ElseIf statements you try to change the
BackColor
of
L1
but in the Else statement you try and change the BackColor of L2. I
asked
you in my post about this. Duane's code differs from your code in
that
his
code looks at the properties of Section 02 and for ALL conditions
tries
to
change the BackColor of L2.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





I spoke too soon. The code runs, but only the last label is
colored
in.
For
instance, in one group, there are three sections that meet the
criteria,
but
only the last is colored in. Are all labels reformatted according
to
the
last
"for" in the loop?

:

As Steve suggested, you might be able to change all your code to
something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And
Me.PCT

0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand
something
doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


:

In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a
series
of
36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And
Word
Applications
(e-mail address removed)



message
I have a report I would like to convert into a kind of map.
I'm
trying
to
do
this by creating labels that correspond to particular
sections.
If
acreage
in
a section meets certain criteria, the label would be colored
accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code
I'm
using for
an event procedure under the format event for the group
footer
for
each
STR
(made up of 36 sections.) But all my "maps" look the same
and
do
not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other"
And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT >
0.75
Then
 
O

okschlaps

Disregard my last post - the problem was my query. I works and it's
beautiful! Thanks for hanging with me, Steve!

Steve said:
Sorry, my brain was running faster than my typing. Rst.Next should be
Rst.MoveNext.

Steve



okschlaps said:
I'm getting a "Method or data member not found" error at Rst.Next. I've
copied my code in case I've typed something wrong. Thanks
Private Sub Report_Open(Cancel As Integer)
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS As Integer
Dim strS As String
Set Db = CurrentDb
Set Rst = Db.OpenRecordset("qryLANDSECTION")
intS = 0
Do Until Rst.EOF
intS = intS + 1
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Rst.Next
Loop
Rst.Close
Set Rst = Nothing
Set Db = Nothing

End Sub

Steve said:
I copied Duane's code and modified it but neglected to make one change.
Change the code to this:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
intS = 0
Do Until Rst.EOF
intS = intS + 1
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Rst.Next
Loop
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Steve
It ran, but all the labels came out blue.

:

Let's try this ---

Make a copy of your report and let's make some changes. First, make
the
recordsource property blank. Remove all textboxes that show data. Move
your
map labels into the detail section. Make sure your labels are named L1
to
L36 and the captions are 1 to 36. Now I am going to assume you have a
table
named TblLandSection that records the data for the 36 sections and the
fields are Section, Status and Percent. I am assuming all sections are
numbered from 1 to 36. Create a query based on TblLand Section named
QryLandSection and sort ascending on Section.

Put the following code in the report's Open event:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Dim intS as Integer
Dim strS as String
Set DB = CurrentDB
Set Rst = DB.OpenRecordset("QryLandSection")
For intS = 1 to 36
If Rst!Status = "In-Hand" And Rst!PCT > 0.75 Then
Me("L" & intS).BackColor = 16744576
ElseIf Rst!Status = "Leased to other" And Me.PCT > 0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next
Rst.Close
Set Rst = Nothing
Set DB = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




Steve
Yeah, Duane was right, the code should have been for L2 in the
second
loop
(then L3 in the third, etc.) Each Label corresponds to a Section. I
have
them
laid out in a grid (it all has to do with land work.)
I suspect Duane is right, that because my data are in the detail
section
and
the "map" (labels) are in the group footer, it's not processing
correctly.
I
tried to do a print screen of my report, but can't paste it in here.
I'll try to clarify. There are 36 sections. I need each section
represented
on a map, or grid and am using color to indicate the status of that
particular section according to the criteria specified in the code.
So the map looks something like
6 5 4 3 2 1
7 8 9 10 11 12
18 17 16 15 14 13
etc
Each number would be in a label and I'm trying to color these.
Hope that helps and I really appreciate your efforts!

:

Here is the second If loop in your original post --
If Me. = "02" And Me.Status = "In-Hand" And Me.PCT > 0.75 Then
L1.BackColor = 16744576
ElseIf Me. = "02" And Me.Status = "Leased to other" And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L2.BackColor = 16777215
End If

Note in the If and ElseIf statements you try to change the
BackColor
of
L1
but in the Else statement you try and change the BackColor of L2. I
asked
you in my post about this. Duane's code differs from your code in
that
his
code looks at the properties of Section 02 and for ALL conditions
tries
to
change the BackColor of L2.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





I spoke too soon. The code runs, but only the last label is
colored
in.
For
instance, in one group, there are three sections that meet the
criteria,
but
only the last is colored in. Are all labels reformatted according
to
the
last
"for" in the loop?

:

As Steve suggested, you might be able to change all your code to
something
like:
Dim intS as Integer
Dim strS as String
For intS = 1 to 36
strS = Format(intS,"00")
If Me. = strS And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
Me("L" & intS).BackColor = 16744576
ElseIf Me. = strS And Me.Status = "Leased to other" And
Me.PCT

0.75
Me("L" & intS).BackColor = 255
Else
Me("L" & intS).BackColor = 16777215
End If
Next

It isn't clear what your records look like. We understand
something
doesn't
work but we don't know much more.
--
Duane Hookom
Microsoft Access MVP


:

In your second If loop, shouldn't L1 be L2?

This could all be set up in code in a Do loop rather than a
series
of
36 If
loops.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And
Word
Applications
(e-mail address removed)



message
I have a report I would like to convert into a kind of map.
I'm
trying
to
do
this by creating labels that correspond to particular
sections.
If
acreage
in
a section meets certain criteria, the label would be colored
accordingly.
The
labels are arranged contiguously into a map.
However, it's not working. Following is a sample of the code
I'm
using for
an event procedure under the format event for the group
footer
for
each
STR
(made up of 36 sections.) But all my "maps" look the same
and
do
not
reflect
any of the data.
Here's the code:

If Me. = "01" And Me.Status = "In-Hand" And Me.PCT > 0.75
Then
L1.BackColor = 16744576
ElseIf Me. = "01" And Me.Status = "Leased to other"
And
Me.PCT

0.75
Then
L1.BackColor = 255
Else: L1.BackColor = 16777215
End If

If Me. = "02" And Me.Status = "In-Hand" And Me.PCT >
0.75
Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top