Detail format differences

  • Thread starter Thread starter Joe Sutphin
  • Start date Start date
J

Joe Sutphin

The following code works perfectly in Access 2000. However, it fails with
#Name? being displayed instead of the value for sExtPrice. The code is
contained in the Detail_Format section of the Report module. Does anyone
know why this occurs and how to fix it? TIA.

Joe
--
Public sExtPrice As String

Const QUOTE = """"

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim PartsSQL As String
Dim con As ADODB.Connection
Dim rsParts As New ADODB.Recordset

Set con = Application.CurrentProject.Connection

PartsSQL = "SELECT Quotes.QuoteNumber, BOMs.PartNumber, Sum(BOMs.Count) AS
SumOfCount, Sum(BOMs.Quantity) AS SumOfQuantity, Parts.Description,
Parts.CatalogSectionNumber, Parts.ListPrice, BOMs.AttributeType, Parts.UOM "
& _
"FROM Parts RIGHT JOIN (Quotes LEFT JOIN BOMs ON
Quotes.QuoteNumber = BOMs.QuoteNumber) ON Parts.PartNumber = BOMs.PartNumber
" & _
"GROUP BY Quotes.QuoteNumber, BOMs.PartNumber,
Parts.Description, Parts.CatalogSectionNumber, Parts.ListPrice,
BOMs.AttributeType, Parts.UOM " & _
"HAVING Quotes.QuoteNumber=" & QUOTE &
[Report_BillOfMaterial].PartNumber & QUOTE & " And Sum(BOMs.Count) > 0 And
BOMs.AttributeType=0 Or Sum(BOMs.Quantity) > 0 " & _
"ORDER BY Parts.CatalogSectionNumber;"

'open the parts recordset
rsParts.Open PartsSQL, con, adOpenKeyset

If rsParts.State = adStateOpen Then
Do
If [SumOfCount] > 0 And [SumOfQuantity] = 0 Then
sExtPrice = Format([SumOfCount] * [ListPrice], "$0.00")

Else
If [SumOfQuantity] > 0 Then
If [UOM] <> 1 Then
sExtPrice = Format(([ListPrice] / [UOM]) * [SumOfQuantity],
"$0.00")

Else
sExtPrice = Format([ListPrice] * [SumOfQuantity], "$0.00")
End If
End If
End If

rsParts.MoveNext
Loop Until rsParts.EOF
End If
End Sub
 
Joe

We're not there, so we can't see what you're looking at.

Usually, when a control returns "#Name", this indicates that Access doesn't
have a source for the control. Sometimes this can be as simple as a small
typo in the Control Source property.

By the way, since this is a newsgroup dedicated to Forms, a "reports"
question may not get answered as quickly. Have you posted to the Reports
newsgroup?
 
Hi Jeff,

Thanks for the response. However, it's not a typo since I noted the code
example works perfectly in 2000.

Joe
--

Jeff Boyce said:
Joe

We're not there, so we can't see what you're looking at.

Usually, when a control returns "#Name", this indicates that Access
doesn't
have a source for the control. Sometimes this can be as simple as a small
typo in the Control Source property.

By the way, since this is a newsgroup dedicated to Forms, a "reports"
question may not get answered as quickly. Have you posted to the Reports
newsgroup?

--
Regards

Jeff Boyce
<Office/Access MVP>

Joe Sutphin said:
The following code works perfectly in Access 2000. However, it fails with
#Name? being displayed instead of the value for sExtPrice. The code is
contained in the Detail_Format section of the Report module. Does anyone
know why this occurs and how to fix it? TIA.

Joe
--
Public sExtPrice As String

Const QUOTE = """"

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim PartsSQL As String
Dim con As ADODB.Connection
Dim rsParts As New ADODB.Recordset

Set con = Application.CurrentProject.Connection

PartsSQL = "SELECT Quotes.QuoteNumber, BOMs.PartNumber, Sum(BOMs.Count) AS
SumOfCount, Sum(BOMs.Quantity) AS SumOfQuantity, Parts.Description,
Parts.CatalogSectionNumber, Parts.ListPrice, BOMs.AttributeType,
Parts.UOM "
& _
"FROM Parts RIGHT JOIN (Quotes LEFT JOIN BOMs ON
Quotes.QuoteNumber = BOMs.QuoteNumber) ON Parts.PartNumber = BOMs.PartNumber
" & _
"GROUP BY Quotes.QuoteNumber, BOMs.PartNumber,
Parts.Description, Parts.CatalogSectionNumber, Parts.ListPrice,
BOMs.AttributeType, Parts.UOM " & _
"HAVING Quotes.QuoteNumber=" & QUOTE &
[Report_BillOfMaterial].PartNumber & QUOTE & " And Sum(BOMs.Count) > 0
And
BOMs.AttributeType=0 Or Sum(BOMs.Quantity) > 0 " & _
"ORDER BY Parts.CatalogSectionNumber;"

'open the parts recordset
rsParts.Open PartsSQL, con, adOpenKeyset

If rsParts.State = adStateOpen Then
Do
If [SumOfCount] > 0 And [SumOfQuantity] = 0 Then
sExtPrice = Format([SumOfCount] * [ListPrice], "$0.00")

Else
If [SumOfQuantity] > 0 Then
If [UOM] <> 1 Then
sExtPrice = Format(([ListPrice] / [UOM]) * [SumOfQuantity],
"$0.00")

Else
sExtPrice = Format([ListPrice] * [SumOfQuantity],
"$0.00")
End If
End If
End If

rsParts.MoveNext
Loop Until rsParts.EOF
End If
End Sub
 
Joe

Perhaps Access somehow got confused (I'm not ignoring your "2000 version is
working", but I am trying to run down the list of more common reasons).

Give this a try ... open the report (?form) in design mode. Select the
control that's returning "#Name". Select Properties, and select the Control
Source property. Drop the list down and select the name of the underlying
field value. Save and close design mode.

Re-try. Does it still display "#Name"?

--
Regards

Jeff Boyce
<Office/Access MVP>

Joe Sutphin said:
Hi Jeff,

Thanks for the response. However, it's not a typo since I noted the code
example works perfectly in 2000.

Joe
--

Jeff Boyce said:
Joe

We're not there, so we can't see what you're looking at.

Usually, when a control returns "#Name", this indicates that Access
doesn't
have a source for the control. Sometimes this can be as simple as a small
typo in the Control Source property.

By the way, since this is a newsgroup dedicated to Forms, a "reports"
question may not get answered as quickly. Have you posted to the Reports
newsgroup?

--
Regards

Jeff Boyce
<Office/Access MVP>

Joe Sutphin said:
The following code works perfectly in Access 2000. However, it fails with
#Name? being displayed instead of the value for sExtPrice. The code is
contained in the Detail_Format section of the Report module. Does anyone
know why this occurs and how to fix it? TIA.

Joe
--
Public sExtPrice As String

Const QUOTE = """"

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim PartsSQL As String
Dim con As ADODB.Connection
Dim rsParts As New ADODB.Recordset

Set con = Application.CurrentProject.Connection

PartsSQL = "SELECT Quotes.QuoteNumber, BOMs.PartNumber,
Sum(BOMs.Count)
AS
SumOfCount, Sum(BOMs.Quantity) AS SumOfQuantity, Parts.Description,
Parts.CatalogSectionNumber, Parts.ListPrice, BOMs.AttributeType,
Parts.UOM "
& _
"FROM Parts RIGHT JOIN (Quotes LEFT JOIN BOMs ON
Quotes.QuoteNumber = BOMs.QuoteNumber) ON Parts.PartNumber = BOMs.PartNumber
" & _
"GROUP BY Quotes.QuoteNumber, BOMs.PartNumber,
Parts.Description, Parts.CatalogSectionNumber, Parts.ListPrice,
BOMs.AttributeType, Parts.UOM " & _
"HAVING Quotes.QuoteNumber=" & QUOTE &
[Report_BillOfMaterial].PartNumber & QUOTE & " And Sum(BOMs.Count) > 0
And
BOMs.AttributeType=0 Or Sum(BOMs.Quantity) > 0 " & _
"ORDER BY Parts.CatalogSectionNumber;"

'open the parts recordset
rsParts.Open PartsSQL, con, adOpenKeyset

If rsParts.State = adStateOpen Then
Do
If [SumOfCount] > 0 And [SumOfQuantity] = 0 Then
sExtPrice = Format([SumOfCount] * [ListPrice], "$0.00")

Else
If [SumOfQuantity] > 0 Then
If [UOM] <> 1 Then
sExtPrice = Format(([ListPrice] / [UOM]) * [SumOfQuantity],
"$0.00")

Else
sExtPrice = Format([ListPrice] * [SumOfQuantity],
"$0.00")
End If
End If
End If

rsParts.MoveNext
Loop Until rsParts.EOF
End If
End Sub
 
Jeff,

The value is not in that list. It's a variable in the module per my code
example. The value is calculated from two database fields and applied to the
report. It is not a field in the table itself.

Joe
--

Jeff Boyce said:
Joe

Perhaps Access somehow got confused (I'm not ignoring your "2000 version
is
working", but I am trying to run down the list of more common reasons).

Give this a try ... open the report (?form) in design mode. Select the
control that's returning "#Name". Select Properties, and select the
Control
Source property. Drop the list down and select the name of the underlying
field value. Save and close design mode.

Re-try. Does it still display "#Name"?

--
Regards

Jeff Boyce
<Office/Access MVP>

Joe Sutphin said:
Hi Jeff,

Thanks for the response. However, it's not a typo since I noted the code
example works perfectly in 2000.

Joe
--

message
Joe

We're not there, so we can't see what you're looking at.

Usually, when a control returns "#Name", this indicates that Access
doesn't
have a source for the control. Sometimes this can be as simple as a small
typo in the Control Source property.

By the way, since this is a newsgroup dedicated to Forms, a "reports"
question may not get answered as quickly. Have you posted to the Reports
newsgroup?

--
Regards

Jeff Boyce
<Office/Access MVP>

The following code works perfectly in Access 2000. However, it fails with
#Name? being displayed instead of the value for sExtPrice. The code is
contained in the Detail_Format section of the Report module. Does anyone
know why this occurs and how to fix it? TIA.

Joe
--
Public sExtPrice As String

Const QUOTE = """"

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim PartsSQL As String
Dim con As ADODB.Connection
Dim rsParts As New ADODB.Recordset

Set con = Application.CurrentProject.Connection

PartsSQL = "SELECT Quotes.QuoteNumber, BOMs.PartNumber, Sum(BOMs.Count)
AS
SumOfCount, Sum(BOMs.Quantity) AS SumOfQuantity, Parts.Description,
Parts.CatalogSectionNumber, Parts.ListPrice, BOMs.AttributeType,
Parts.UOM
"
& _
"FROM Parts RIGHT JOIN (Quotes LEFT JOIN BOMs ON
Quotes.QuoteNumber = BOMs.QuoteNumber) ON Parts.PartNumber =
BOMs.PartNumber
" & _
"GROUP BY Quotes.QuoteNumber, BOMs.PartNumber,
Parts.Description, Parts.CatalogSectionNumber, Parts.ListPrice,
BOMs.AttributeType, Parts.UOM " & _
"HAVING Quotes.QuoteNumber=" & QUOTE &
[Report_BillOfMaterial].PartNumber & QUOTE & " And Sum(BOMs.Count) > 0
And
BOMs.AttributeType=0 Or Sum(BOMs.Quantity) > 0 " & _
"ORDER BY Parts.CatalogSectionNumber;"

'open the parts recordset
rsParts.Open PartsSQL, con, adOpenKeyset

If rsParts.State = adStateOpen Then
Do
If [SumOfCount] > 0 And [SumOfQuantity] = 0 Then
sExtPrice = Format([SumOfCount] * [ListPrice], "$0.00")

Else
If [SumOfQuantity] > 0 Then
If [UOM] <> 1 Then
sExtPrice = Format(([ListPrice] / [UOM]) * [SumOfQuantity],
"$0.00")

Else
sExtPrice = Format([ListPrice] * [SumOfQuantity],
"$0.00")
End If
End If
End If

rsParts.MoveNext
Loop Until rsParts.EOF
End If
End Sub
 
Joe

I'm not sure I understand the complexity of what you are trying to do.

Are you saying that you want to do a calculation and put the value in a
control on your report?

While the Sub you posted earlier may be able to calculate the value you
seek, I don't think Sub's return values. Have you tried it as a Function,
declaring a return datatype?

--
Regards

Jeff Boyce
<Office/Access MVP>

Joe Sutphin said:
Jeff,

The value is not in that list. It's a variable in the module per my code
example. The value is calculated from two database fields and applied to the
report. It is not a field in the table itself.

Joe
--

Jeff Boyce said:
Joe

Perhaps Access somehow got confused (I'm not ignoring your "2000 version
is
working", but I am trying to run down the list of more common reasons).

Give this a try ... open the report (?form) in design mode. Select the
control that's returning "#Name". Select Properties, and select the
Control
Source property. Drop the list down and select the name of the underlying
field value. Save and close design mode.

Re-try. Does it still display "#Name"?

--
Regards

Jeff Boyce
<Office/Access MVP>

Joe Sutphin said:
Hi Jeff,

Thanks for the response. However, it's not a typo since I noted the code
example works perfectly in 2000.

Joe
--

message
Joe

We're not there, so we can't see what you're looking at.

Usually, when a control returns "#Name", this indicates that Access
doesn't
have a source for the control. Sometimes this can be as simple as a small
typo in the Control Source property.

By the way, since this is a newsgroup dedicated to Forms, a "reports"
question may not get answered as quickly. Have you posted to the Reports
newsgroup?

--
Regards

Jeff Boyce
<Office/Access MVP>

The following code works perfectly in Access 2000. However, it fails with
#Name? being displayed instead of the value for sExtPrice. The code is
contained in the Detail_Format section of the Report module. Does anyone
know why this occurs and how to fix it? TIA.

Joe
--
Public sExtPrice As String

Const QUOTE = """"

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim PartsSQL As String
Dim con As ADODB.Connection
Dim rsParts As New ADODB.Recordset

Set con = Application.CurrentProject.Connection

PartsSQL = "SELECT Quotes.QuoteNumber, BOMs.PartNumber, Sum(BOMs.Count)
AS
SumOfCount, Sum(BOMs.Quantity) AS SumOfQuantity, Parts.Description,
Parts.CatalogSectionNumber, Parts.ListPrice, BOMs.AttributeType,
Parts.UOM
"
& _
"FROM Parts RIGHT JOIN (Quotes LEFT JOIN BOMs ON
Quotes.QuoteNumber = BOMs.QuoteNumber) ON Parts.PartNumber =
BOMs.PartNumber
" & _
"GROUP BY Quotes.QuoteNumber, BOMs.PartNumber,
Parts.Description, Parts.CatalogSectionNumber, Parts.ListPrice,
BOMs.AttributeType, Parts.UOM " & _
"HAVING Quotes.QuoteNumber=" & QUOTE &
[Report_BillOfMaterial].PartNumber & QUOTE & " And Sum(BOMs.Count) > 0
And
BOMs.AttributeType=0 Or Sum(BOMs.Quantity) > 0 " & _
"ORDER BY Parts.CatalogSectionNumber;"

'open the parts recordset
rsParts.Open PartsSQL, con, adOpenKeyset

If rsParts.State = adStateOpen Then
Do
If [SumOfCount] > 0 And [SumOfQuantity] = 0 Then
sExtPrice = Format([SumOfCount] * [ListPrice], "$0.00")

Else
If [SumOfQuantity] > 0 Then
If [UOM] <> 1 Then
sExtPrice = Format(([ListPrice] / [UOM]) * [SumOfQuantity],
"$0.00")

Else
sExtPrice = Format([ListPrice] * [SumOfQuantity],
"$0.00")
End If
End If
End If

rsParts.MoveNext
Loop Until rsParts.EOF
End If
End Sub
 
Thanks Jeff, but I'm going to go about it a different manner.

However, to answer your question, I don't understand why the exact some code
works in 2000 and not 2003.

The only thing that I do differently is I open the database file with Access
2003 instead of Access 2000. Thats it, nothing else changes.

Joe
--

Jeff Boyce said:
Joe

I'm not sure I understand the complexity of what you are trying to do.

Are you saying that you want to do a calculation and put the value in a
control on your report?

While the Sub you posted earlier may be able to calculate the value you
seek, I don't think Sub's return values. Have you tried it as a Function,
declaring a return datatype?

--
Regards

Jeff Boyce
<Office/Access MVP>

Joe Sutphin said:
Jeff,

The value is not in that list. It's a variable in the module per my code
example. The value is calculated from two database fields and applied to the
report. It is not a field in the table itself.

Joe
--

message
Joe

Perhaps Access somehow got confused (I'm not ignoring your "2000
version
is
working", but I am trying to run down the list of more common reasons).

Give this a try ... open the report (?form) in design mode. Select the
control that's returning "#Name". Select Properties, and select the
Control
Source property. Drop the list down and select the name of the underlying
field value. Save and close design mode.

Re-try. Does it still display "#Name"?

--
Regards

Jeff Boyce
<Office/Access MVP>

Hi Jeff,

Thanks for the response. However, it's not a typo since I noted the code
example works perfectly in 2000.

Joe
--

message
Joe

We're not there, so we can't see what you're looking at.

Usually, when a control returns "#Name", this indicates that Access
doesn't
have a source for the control. Sometimes this can be as simple as a
small
typo in the Control Source property.

By the way, since this is a newsgroup dedicated to Forms, a
"reports"
question may not get answered as quickly. Have you posted to the
Reports
newsgroup?

--
Regards

Jeff Boyce
<Office/Access MVP>

The following code works perfectly in Access 2000. However, it
fails
with
#Name? being displayed instead of the value for sExtPrice. The code is
contained in the Detail_Format section of the Report module. Does
anyone
know why this occurs and how to fix it? TIA.

Joe
--
Public sExtPrice As String

Const QUOTE = """"

Private Sub Detail_Format(Cancel As Integer, FormatCount As
Integer)
Dim PartsSQL As String
Dim con As ADODB.Connection
Dim rsParts As New ADODB.Recordset

Set con = Application.CurrentProject.Connection

PartsSQL = "SELECT Quotes.QuoteNumber, BOMs.PartNumber,
Sum(BOMs.Count)
AS
SumOfCount, Sum(BOMs.Quantity) AS SumOfQuantity, Parts.Description,
Parts.CatalogSectionNumber, Parts.ListPrice, BOMs.AttributeType,
Parts.UOM
"
& _
"FROM Parts RIGHT JOIN (Quotes LEFT JOIN BOMs ON
Quotes.QuoteNumber = BOMs.QuoteNumber) ON Parts.PartNumber =
BOMs.PartNumber
" & _
"GROUP BY Quotes.QuoteNumber, BOMs.PartNumber,
Parts.Description, Parts.CatalogSectionNumber, Parts.ListPrice,
BOMs.AttributeType, Parts.UOM " & _
"HAVING Quotes.QuoteNumber=" & QUOTE &
[Report_BillOfMaterial].PartNumber & QUOTE & " And Sum(BOMs.Count)
0
And
BOMs.AttributeType=0 Or Sum(BOMs.Quantity) > 0 " & _
"ORDER BY Parts.CatalogSectionNumber;"

'open the parts recordset
rsParts.Open PartsSQL, con, adOpenKeyset

If rsParts.State = adStateOpen Then
Do
If [SumOfCount] > 0 And [SumOfQuantity] = 0 Then
sExtPrice = Format([SumOfCount] * [ListPrice], "$0.00")

Else
If [SumOfQuantity] > 0 Then
If [UOM] <> 1 Then
sExtPrice = Format(([ListPrice] / [UOM]) *
[SumOfQuantity],
"$0.00")

Else
sExtPrice = Format([ListPrice] * [SumOfQuantity],
"$0.00")
End If
End If
End If

rsParts.MoveNext
Loop Until rsParts.EOF
End If
End Sub
 
Joe

I occasionally run across a bit of code, a query, a report ... that works
one day and not the next. After trying all the possibilities I can think
of, I generally throw out the old and recreate it. My interpretation is
that Access sometimes gets subtly 'munged' (something that Compact & Repair
doesn't fix, and something that Debug/Compile doesn't catch). Not very
often, but when it happens, throwing out the old object and starting over
seems to do the trick.

Good luck

Jeff Boyce
<Office/Access MVP>

Joe Sutphin said:
Thanks Jeff, but I'm going to go about it a different manner.

However, to answer your question, I don't understand why the exact some code
works in 2000 and not 2003.

The only thing that I do differently is I open the database file with Access
2003 instead of Access 2000. Thats it, nothing else changes.

Joe
--

Jeff Boyce said:
Joe

I'm not sure I understand the complexity of what you are trying to do.

Are you saying that you want to do a calculation and put the value in a
control on your report?

While the Sub you posted earlier may be able to calculate the value you
seek, I don't think Sub's return values. Have you tried it as a Function,
declaring a return datatype?

--
Regards

Jeff Boyce
<Office/Access MVP>

Joe Sutphin said:
Jeff,

The value is not in that list. It's a variable in the module per my code
example. The value is calculated from two database fields and applied
to
the
report. It is not a field in the table itself.

Joe
--

message
Joe

Perhaps Access somehow got confused (I'm not ignoring your "2000
version
is
working", but I am trying to run down the list of more common reasons).

Give this a try ... open the report (?form) in design mode. Select the
control that's returning "#Name". Select Properties, and select the
Control
Source property. Drop the list down and select the name of the underlying
field value. Save and close design mode.

Re-try. Does it still display "#Name"?

--
Regards

Jeff Boyce
<Office/Access MVP>

Hi Jeff,

Thanks for the response. However, it's not a typo since I noted the code
example works perfectly in 2000.

Joe
--

message
Joe

We're not there, so we can't see what you're looking at.

Usually, when a control returns "#Name", this indicates that Access
doesn't
have a source for the control. Sometimes this can be as simple as a
small
typo in the Control Source property.

By the way, since this is a newsgroup dedicated to Forms, a
"reports"
question may not get answered as quickly. Have you posted to the
Reports
newsgroup?

--
Regards

Jeff Boyce
<Office/Access MVP>

The following code works perfectly in Access 2000. However, it
fails
with
#Name? being displayed instead of the value for sExtPrice. The
code
is
contained in the Detail_Format section of the Report module. Does
anyone
know why this occurs and how to fix it? TIA.

Joe
--
Public sExtPrice As String

Const QUOTE = """"

Private Sub Detail_Format(Cancel As Integer, FormatCount As
Integer)
Dim PartsSQL As String
Dim con As ADODB.Connection
Dim rsParts As New ADODB.Recordset

Set con = Application.CurrentProject.Connection

PartsSQL = "SELECT Quotes.QuoteNumber, BOMs.PartNumber,
Sum(BOMs.Count)
AS
SumOfCount, Sum(BOMs.Quantity) AS SumOfQuantity, Parts.Description,
Parts.CatalogSectionNumber, Parts.ListPrice, BOMs.AttributeType,
Parts.UOM
"
& _
"FROM Parts RIGHT JOIN (Quotes LEFT JOIN BOMs ON
Quotes.QuoteNumber = BOMs.QuoteNumber) ON Parts.PartNumber =
BOMs.PartNumber
" & _
"GROUP BY Quotes.QuoteNumber, BOMs.PartNumber,
Parts.Description, Parts.CatalogSectionNumber, Parts.ListPrice,
BOMs.AttributeType, Parts.UOM " & _
"HAVING Quotes.QuoteNumber=" & QUOTE &
[Report_BillOfMaterial].PartNumber & QUOTE & " And Sum(BOMs.Count)
0
And
BOMs.AttributeType=0 Or Sum(BOMs.Quantity) > 0 " & _
"ORDER BY Parts.CatalogSectionNumber;"

'open the parts recordset
rsParts.Open PartsSQL, con, adOpenKeyset

If rsParts.State = adStateOpen Then
Do
If [SumOfCount] > 0 And [SumOfQuantity] = 0 Then
sExtPrice = Format([SumOfCount] * [ListPrice], "$0.00")

Else
If [SumOfQuantity] > 0 Then
If [UOM] <> 1 Then
sExtPrice = Format(([ListPrice] / [UOM]) *
[SumOfQuantity],
"$0.00")

Else
sExtPrice = Format([ListPrice] * [SumOfQuantity],
"$0.00")
End If
End If
End If

rsParts.MoveNext
Loop Until rsParts.EOF
End If
End Sub
 
Back
Top