If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
#Name? error in the group footer
This is a duplicate of the subject I posted this morning about Conversion
from Access 97 to Access 2003. I'm reposting because the subject may have been misleading. ---------------------------------------------------------------------------------------- I converted an Access 97 database to Access 2003. When I view one of the reports, a Text Box in the group footer now displays #Name?. The Text Box Control Source contains =[strTopPowerRating]. strTopPowerRating is a variable declared in a module that is stored with the report. It gets reset in GroupHeader1_Format and is calculated in Detail_Format. ----------------------------------------------------------------------------------- Option Compare Database Option Explicit Public strTopPowerRating As String ----------------------------------------------------------------------------------- Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If Expr1000 = "TopPowerRating" Then strTopPowerRating = "X" End If End Sub ---------------------------------------------------------------------------------- Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer) strTopPowerRating = " " End Sub ---------------------------------------------------------------------------------- I've run the debugger and watched the value in strTopPowerRating. It is calculated properly in Detail_Format and keeps it's value until being reset to a blank in GroupHeader1_Format. For some reason, the Text Box is not able to pull in the value of strTopPowerRating in my Access 2003 database. Any suggestions would be greatly appreciated. -- Thanks, SCONE |
#2
|
|||
|
|||
Variables in VBA code are not available directly to textboxes and other
controls on a report or form. When you type =[strTopPowerRating] in a control source for a textbox, you're telling ACCESS to get the value from the field or control named strTopPowerRating -- and of course, because there is no such control or field in the report, you get the #Name? error. You could go the long way around and write a public function that will get the value of the variable and return it as the function's value, and then use the function in the control source expression: =MyPublicFunctionToGetValueOfstrTopPowerRating() But why not just use the Format event code to write the value into the textbox: Private Sub GroupFooternName_Format(Cancel As Integer, FormatCount As Integer) If Expr1000 = "TopPowerRating" Then strTopPowerRating = "X" End If Me.TextBoxNameInFooter.Value = strTopPowerRating End Sub -- Ken Snell MS ACCESS MVP "SCONE" wrote in message news This is a duplicate of the subject I posted this morning about Conversion from Access 97 to Access 2003. I'm reposting because the subject may have been misleading. ---------------------------------------------------------------------------------------- I converted an Access 97 database to Access 2003. When I view one of the reports, a Text Box in the group footer now displays #Name?. The Text Box Control Source contains =[strTopPowerRating]. strTopPowerRating is a variable declared in a module that is stored with the report. It gets reset in GroupHeader1_Format and is calculated in Detail_Format. ----------------------------------------------------------------------------------- Option Compare Database Option Explicit Public strTopPowerRating As String ----------------------------------------------------------------------------------- Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If Expr1000 = "TopPowerRating" Then strTopPowerRating = "X" End If End Sub ---------------------------------------------------------------------------------- Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer) strTopPowerRating = " " End Sub ---------------------------------------------------------------------------------- I've run the debugger and watched the value in strTopPowerRating. It is calculated properly in Detail_Format and keeps it's value until being reset to a blank in GroupHeader1_Format. For some reason, the Text Box is not able to pull in the value of strTopPowerRating in my Access 2003 database. Any suggestions would be greatly appreciated. -- Thanks, SCONE |
#3
|
|||
|
|||
Suggestion 2 was perfect. Thanks for the explanation and recommendations.
"Ken Snell [MVP]" wrote: Variables in VBA code are not available directly to textboxes and other controls on a report or form. When you type =[strTopPowerRating] in a control source for a textbox, you're telling ACCESS to get the value from the field or control named strTopPowerRating -- and of course, because there is no such control or field in the report, you get the #Name? error. You could go the long way around and write a public function that will get the value of the variable and return it as the function's value, and then use the function in the control source expression: =MyPublicFunctionToGetValueOfstrTopPowerRating() But why not just use the Format event code to write the value into the textbox: Private Sub GroupFooternName_Format(Cancel As Integer, FormatCount As Integer) If Expr1000 = "TopPowerRating" Then strTopPowerRating = "X" End If Me.TextBoxNameInFooter.Value = strTopPowerRating End Sub -- Ken Snell MS ACCESS MVP "SCONE" wrote in message news This is a duplicate of the subject I posted this morning about Conversion from Access 97 to Access 2003. I'm reposting because the subject may have been misleading. ---------------------------------------------------------------------------------------- I converted an Access 97 database to Access 2003. When I view one of the reports, a Text Box in the group footer now displays #Name?. The Text Box Control Source contains =[strTopPowerRating]. strTopPowerRating is a variable declared in a module that is stored with the report. It gets reset in GroupHeader1_Format and is calculated in Detail_Format. ----------------------------------------------------------------------------------- Option Compare Database Option Explicit Public strTopPowerRating As String ----------------------------------------------------------------------------------- Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If Expr1000 = "TopPowerRating" Then strTopPowerRating = "X" End If End Sub ---------------------------------------------------------------------------------- Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer) strTopPowerRating = " " End Sub ---------------------------------------------------------------------------------- I've run the debugger and watched the value in strTopPowerRating. It is calculated properly in Detail_Format and keeps it's value until being reset to a blank in GroupHeader1_Format. For some reason, the Text Box is not able to pull in the value of strTopPowerRating in my Access 2003 database. Any suggestions would be greatly appreciated. -- Thanks, SCONE |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Print Group Footer in Set Location | Vandy | Setting Up & Running Reports | 1 | February 2nd, 2005 10:53 PM |
Hide group footer based on field value | Paul Kraemer | Setting Up & Running Reports | 1 | January 31st, 2005 09:13 PM |
Hide group footer based on field value | Paul Kraemer via AccessMonster.com | Setting Up & Running Reports | 0 | January 31st, 2005 07:04 PM |
Using DCount in Group Footer filtering records based on value of the group | Beth | Setting Up & Running Reports | 1 | September 10th, 2004 04:17 PM |
how divide detail by group footer total | Dan | Setting Up & Running Reports | 3 | May 25th, 2004 07:28 PM |