473,803 Members | 3,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting #Name? in All Report Fields

55 New Member
Tomorrow's my final presentation of my DB and I ran into an unexpected problem: I access a main form called frmViewAllResou rces with several tabbed subforms through my switchboard. There's a preview and print button on the main form that generates a report called "Commoditie s." It previews and prints all the relevant fields from the main form and subform just fine.

On my switchboard, I can also access a form to print reports using a date range. My sample report "Commoditie s," which was auto-wizarded on tblResources (frmViewAllReso urces) worked just fine an hour ago. Then, I opened the report and started adding textboxes and comboboxes that linked to other forms (i.e. the subforms in frmViewAllResou rces). After flipping back to form view, all the boxes displayed the correct information for all 4 dummy records.

However, once I opened up the form to print reports by date range and selected "Commoditie s," the report opened up with "#Name?" in all fields. This is the code I'm using for my date range form:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdPrintPreview_Click()
  2.  
  3.     Dim strField As String      'Name of your date field.
  4.     Dim strWhere As String      'Where condition for OpenReport.
  5.     Const conDateFormat = "\#mm\/dd\/yyyy\#"
  6.  
  7.     strField = "RecordDate"
  8.  
  9.     If Not IsNull(cmbReports) And cmbReports <> "<select>" Then
  10.         If IsNull(Me.txtStartDate) Then
  11.             If Not IsNull(Me.txtEndDate) Then   'End date, but no start.
  12.                 strWhere = strField & " <= " & Format(Me.txtEndDate, conDateFormat)
  13.             End If
  14.         Else
  15.             If IsNull(Me.txtEndDate) Then       'Start date, but no End.
  16.                 strWhere = strField & " >= " & Format(Me.txtStartDate, conDateFormat)
  17.             Else                                'Both start and end dates.
  18.                 strWhere = strField & " Between " & Format(Me.txtStartDate, conDateFormat) _
  19.                     & " And " & Format(Me.txtEndDate, conDateFormat)
  20.             End If
  21.         End If
  22.     Else
  23.         MsgBox ("You Must First Select a Report To Preview!")
  24.         cmbReports.SetFocus
  25.     End If
  26.  
  27.     ' Debug.Print strWhere                  'For debugging purposes only.
  28.     DoCmd.OpenReport cmbReports, acViewPreview, , strWhere
  29. End Sub
Would anything here having anything to do with my form's phenomenon? Or, should I instead have my report's fields refer to the tables instead of the forms? Linking to the tables makes much more sense, so I'm going to try that. I apologize for not trying it before posting, but my time is limited so I'll need some ready advice if it doesn't work. Thanks.
Dec 10 '07 #1
11 1764
JustJim
407 Recognized Expert Contributor
Tomorrow's my final presentation of my DB and I ran into an unexpected problem: I access a main form called frmViewAllResou rces with several tabbed subforms through my switchboard. There's a preview and print button on the main form that generates a report called "Commoditie s." It previews and prints all the relevant fields from the main form and subform just fine.

On my switchboard, I can also access a form to print reports using a date range. My sample report "Commoditie s," which was auto-wizarded on tblResources (frmViewAllReso urces) worked just fine an hour ago. Then, I opened the report and started adding textboxes and comboboxes that linked to other forms (i.e. the subforms in frmViewAllResou rces). After flipping back to form view, all the boxes displayed the correct information for all 4 dummy records.

However, once I opened up the form to print reports by date range and selected "Commoditie s," the report opened up with "#Name?" in all fields. This is the code I'm using for my date range form:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdPrintPreview_Click()
  2.  
  3.     Dim strField As String      'Name of your date field.
  4.     Dim strWhere As String      'Where condition for OpenReport.
  5.     Const conDateFormat = "\#mm\/dd\/yyyy\#"
  6.  
  7.     strField = "RecordDate"
  8.  
  9.     If Not IsNull(cmbReports) And cmbReports <> "<select>" Then
  10.         If IsNull(Me.txtStartDate) Then
  11.             If Not IsNull(Me.txtEndDate) Then   'End date, but no start.
  12.                 strWhere = strField & " <= " & Format(Me.txtEndDate, conDateFormat)
  13.             End If
  14.         Else
  15.             If IsNull(Me.txtEndDate) Then       'Start date, but no End.
  16.                 strWhere = strField & " >= " & Format(Me.txtStartDate, conDateFormat)
  17.             Else                                'Both start and end dates.
  18.                 strWhere = strField & " Between " & Format(Me.txtStartDate, conDateFormat) _
  19.                     & " And " & Format(Me.txtEndDate, conDateFormat)
  20.             End If
  21.         End If
  22.     Else
  23.         MsgBox ("You Must First Select a Report To Preview!")
  24.         cmbReports.SetFocus
  25.     End If
  26.  
  27.     ' Debug.Print strWhere                  'For debugging purposes only.
  28.     DoCmd.OpenReport cmbReports, acViewPreview, , strWhere
  29. End Sub
Would anything here having anything to do with my form's phenomenon? Or, should I instead have my report's fields refer to the tables instead of the forms? Linking to the tables makes much more sense, so I'm going to try that. I apologize for not trying it before posting, but my time is limited so I'll need some ready advice if it doesn't work. Thanks.
I think that it is likely to be the way you are referring to the sub-forms. Check out this thread for details on how to do this elegantly.

Jim
Dec 10 '07 #2
BASSPU03
55 New Member
I think that it is likely to be the way you are referring to the sub-forms. Check out this thread for details on how to do this elegantly.

Jim
Thanks, Jim. I've used the expression builder and believe that I've correctly linked to the sub-forms through the loaded forms. The problem appears to extend to the main form as well. I'll keep plugging away on my end, but any further thoughts would be appreciated.
Dec 10 '07 #3
JustJim
407 Recognized Expert Contributor
Thanks, Jim. I've used the expression builder and believe that I've correctly linked to the sub-forms through the loaded forms. The problem appears to extend to the main form as well. I'll keep plugging away on my end, but any further thoughts would be appreciated.
Post a copy of the Control Source of a control on the main form and one from a sub form and we'll have a look.

Jim
Dec 10 '07 #4
BASSPU03
55 New Member
Post a copy of the Control Source of a control on the main form and one from a sub form and we'll have a look.

Jim
Here's some new information: The main form control sources are now working. It turns out the report is based on the table (tblResources) and only needs a field reference (e.g. AutoNumber) and not the whole "Forms!frmView. ..etc." syntax. They would work some of the time because they were referencing the right controls on the right form when it was loaded (i.e. open). When I'd close the corresponding form that was open in the background, the "#Name?" would appear in the fields of the report. So, not only did I solve that "#Name?" mystery, but I've also corrected the references.

However, I'm still having a problem with the subform references. In control source "Requestedb y," I've tried the following:

=Forms!frmViewA llResources!sfr mAdminTab.Form! AdminRequestedb y

No such luck with the subform references. Any ideas? Thanks.

P.S. A space inadvertently appears in "AdminRequested by" on this post. It looks like "Admin Requestedby," but should be the former.
Dec 11 '07 #5
JustJim
407 Recognized Expert Contributor
Here's some new information: The main form control sources are now working. It turns out the report is based on the table (tblResources) and only needs a field reference (e.g. AutoNumber) and not the whole "Forms!frmView. ..etc." syntax. They would work some of the time because they were referencing the right controls on the right form when it was loaded (i.e. open). When I'd close the corresponding form that was open in the background, the "#Name?" would appear in the fields of the report. So, not only did I solve that "#Name?" mystery, but I've also corrected the references.

However, I'm still having a problem with the subform references. In control source "Requestedb y," I've tried the following:

=Forms!frmViewA llResources!sfr mAdminTab.Form! AdminRequestedb y

No such luck with the subform references. Any ideas? Thanks.

P.S. A space inadvertently appears in "AdminRequested by" on this post. It looks like "Admin Requestedby," but should be the former.
The easy one first... use Code Tags around code and you will get a better appearance. Add an equals sign and either vb or sql or text just before the closing square bracket of the opening tag for added functionallity.

Second, try the other two methods listed below, shouldn't make a jot of difference, but hey, you never know.
Expand|Select|Wrap|Line Numbers
  1. Forms![FormName]![SubFormName].Form![ControlName]
  2. Forms("FormName")![SubFormName].Form![ControlName]
  3. Form_FormName![SubFormName].Form![ControlName]
Jim
Dec 11 '07 #6
BASSPU03
55 New Member
The easy one first... use Code Tags around code and you will get a better appearance. Add an equals sign and either vb or sql or text just before the closing square bracket of the opening tag for added functionallity.
Yeah, sorry about that! I always forget to encircle one-line codes with the Code Tags.

Second, try the other two methods listed below, shouldn't make a jot of difference, but hey, you never know.
Expand|Select|Wrap|Line Numbers
  1. Forms![FormName]![SubFormName].Form![ControlName]
  2. Forms("FormName")![SubFormName].Form![ControlName]
  3. Form_FormName![SubFormName].Form![ControlName]
Jim
I tried them--no luck. I think I'm going to try just using the wizard to create the subforms within the reports. I initially created the report with all unbound controls (in order to design it "freehand") and then wanted to associate all the controls accordingly afterwards. Well, I don't know why I'm still having trouble even with the expression builder.

I'd be happy to hear any other thoughts. In the meantime, I'll work on it and then post back any progress. Thanks.
Dec 11 '07 #7
BASSPU03
55 New Member
OK, the main problem is this: The report is bound to "tblResourc es," which makes it easy to bind any unbound control, as long as the control source is a field (e.g. Resource) in tblResources. However, if I have an unbound control refer to another table's/form's control, then I get "#Name?" in those controls. Why? Apparently, it's because the form (i.e. the one to which these controls refer) isn't loaded (i.e. open.)

So, it's not so much that my references are incorrect. If I open the form (frmViewAllReso urces) to which the controls refer and then run the report over that open window, all the "subreport" controls work. How do I load the form frmViewAllResou rces hidden in the background when I preview the report? Is this a good way to approach it?

Thanks.
Dec 12 '07 #8
JustJim
407 Recognized Expert Contributor
OK, the main problem is this: The report is bound to "tblResourc es," which makes it easy to bind any unbound control, as long as the control source is a field (e.g. Resource) in tblResources. However, if I have an unbound control refer to another table's/form's control, then I get "#Name?" in those controls. Why? Apparently, it's because the form (i.e. the one to which these controls refer) isn't loaded (i.e. open.)

So, it's not so much that my references are incorrect. If I open the form (frmViewAllReso urces) to which the controls refer and then run the report over that open window, all the "subreport" controls work. How do I load the form frmViewAllResou rces hidden in the background when I preview the report? Is this a good way to approach it?

Thanks.
Try this
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmViewAllResources", , , , , acHidden
Jim
Dec 12 '07 #9
BASSPU03
55 New Member
A short follow-up to my attempt to auto-wizard drag-&-drop subforms into the report:

The beauty of just dropping an auto-wizard subform into the report is that it allows you to link the controls using a parent/child relationship. I tried this and formatted each subform dropped into the report as if I were using unbound controls that I could just move around and manipulate. I was very pleased. Sadly, when I went back to frmViewAllResou rces and clicked on the tabbed subforms, all the subforms' designs were changed to look like what I had formatted on the report! It's a GOOOOOD thing that I'd saved many backups of my DB. All I had to do to recover the design of each subform was copy the controls from an old DB version and paste 'em in the current copy.

Try this
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmViewAllResources", , , , , acHidden
Jim
Jim, that's a great suggestion. This allows me to format the report like I want with unbound controls. Loading frmViewAllResou rces in the background works well to successfully display the information. However, because these unbound controls aren't linked (by AutoNumber) to the main form's report controls, the records don't change. It displays File Number 130 with all the main form controls and the correct subform controls, but the subform controls don't change when I print preview pages and view File Number 131.

If I tried (and I have) to link the unbound controls to the tables (as opposed to the forms), I believe I'd still have no way to make the records correspond to the main forms' controls. I'm pretty sure I'd get "Enter Parameter Value" for each unbound subform control upon initializing the report.

Is there a way to make the control source of the report be multiple forms/subforms, which'll then allow the controls to draw from various sources? I'd say this report issue is keeping me from fixing and finishing my DB. All your help thus far has been grand.
Dec 13 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

15
7976
by: U N Me | last post by:
I have a continuous form that lists records from a query. One of the columns is an amount field, In the footer of the form I place a text box that displays the total (sum) of the amount. The data in the form is linked from a one-to-many table relationship. In this instance, I really can't sum the value from the one's table since if there were 3 records in the many table for a record id, the value would be summed 3 times. IOW, I may be...
3
3717
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what a spreadsheet might show, the column names will actually be dynamic, based on data from a SQL Server 2000 database. The row data will also come from the same database. So in this case, I will have a main report and a subreport. I've already tried...
2
1845
by: LoopyNZ | last post by:
Hi, (Access 97) I'm creating a query (QRY_SUMMARY) to join a query (QRY) to itself (QRY_1). I'm returning QRY.* and selected fields from QRY_1. With each field (field_name) I return from QRY_1 I'm appending "_1" to to the end to avoid name conflicts with the fields from QRY, i.e. "field_name" becomes "field_name_1".
22
6803
by: PeteCresswell | last post by:
I've been to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mschrt/html/vbobjtitleobject.asp, but still don't have a clue. For example, I've got a chart object namde 'grphStats' in a form named frmChart. ?Forms!frmChart!grphStats.Name returns "grphStats" as expected, but I can't get any further.
1
2700
by: kkrizl | last post by:
I have a form that displays general information about an alarm permit location. There's a subform that shows detailed information about burglar alarms that have gone off at the location. When a new alarm is entered on the subform, I want to print a report that shows the general information and the alarms that were entered. The record source for the form is the Mailing List table (key is Alarm #). The record source for the subform is the...
3
4096
by: Daron | last post by:
Is it possible to use a parameter as the field name, not just a criteria? Snippet of my SQL: SELECT Eval("!!.(0)") AS TestField, AS from qry_main The parameter will hold the name of the field. In the first column, I want to show the name of the field for all records. In the
12
2248
by: Orchid | last post by:
Hello all, I have different version of reports which used for different months. For example, I am using report version 1 up to September, but we have some design changes on the report for October, so I created report version 2. I want a same Command Button to open the appropriated version report for the specific month. I create a table with the following Fields: Month, ReportID, ReportToOpen (this is the exact report name). On a form,...
1
2617
by: Chris White | last post by:
Here's my XML <?xml version="1.0" encoding="UTF-8"?> <results> <status code="ok"/> <report-bulk-users> <row principal-id="23859115" type="user"> <login>muser@domain.com</login> <name>My User</name> <email>myuser@domain.com</email> <manager>manager@domain.com</manager>
2
4451
by: srusskinyon | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for statistical purposes. I've been using Here's the situation: I have two main tables:
0
10546
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10292
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.