473,395 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Create row numbers on a subform in Access 2010

9
I have an Access DB that I'm attempting, for display purposes, to add an unbound text field to a continuous subform that contains a row number for each record. From a really old previous post I can make it work when I open the subform by itself, but it does not work when I open the main form with the subform attached.

The public module code is written:

Expand|Select|Wrap|Line Numbers
  1. Public Function RowNum(frm As Form) As Variant
  2.   On Error GoTo Err_RowNum
  3.       'Purpose:   Numbering the rows on a form.
  4.       'Usage:     Text box with ControlSource of:  =RowNum([Forms]![myForm])
  5.  
  6.       With frm.RecordsetClone
  7.           .Bookmark = frm.Bookmark
  8.          RowNum = .AbsolutePosition + 1
  9.       End With
  10.  
  11.   Exit_RowNum:
  12.       Exit Function
  13.  
  14.   Err_RowNum:
  15.       If Err.Number <> 3021& Then  'Ignore "No bookmark" at new row.
  16.           Debug.Print "RowNum() error " & Err.Number & " - " & Err.Description
  17.       End If
  18.       RowNum = Null
  19.       Resume Exit_RowNum
  20. End Function
  21.  
The text field, in the subform, is titled "RowNum" and I have the following as the control source:
=RowNum([Forms]![frmMainForm]![Child3].Form)

I've tried so many different ways and either get #Name or #Error.

Please help!
Dec 8 '15 #1

✓ answered by zmbd


Control Name and Function Name are the same.
I would start with changing the control name to something else - I would suspect that is the source of the #Name errors

14 5614
mbizup
80 64KB
Have you tried just passing the path to the subform when calling the function? I don't think you need the ".Form" in control sources or queries.

=RowNum(Forms]![frmMainForm]![Child3])
Dec 8 '15 #2
zmbd
5,501 Expert Mod 4TB
Referring to subforms is a real treat sometimes.

Often the errors come across to me, especially at midnight, as:
#Name = I can't find the object you're talking about, are you sure you know what you're doing - go back to bed!
#Error = What are you thinking... I can't read your mind, fix this after you've had a serious nap.
#Type = Really, you're not seriously trying to pass/return the wrong data-type, go count some sheeps, ducks, squirrels!

I have a form and subform where in I use IIF() and UDF to determine if the subform is being opened as standalone or as part of a navigation control form object.... that was a real treat, not.

Anyway,

=RowNum([Forms]![ParentFormName]![SubForm_container_Name].[Form])

Say I had:
+ Parent form named [Form1]
+ On [Form1] that form I had the subform container named:
[frmQuery1_container]
+ that held the subform named [frmQuery1]

then the reference for your function would be:
=RowNum([Forms]![Form1]![frmQuery1_container].[Form])
>>> NOTE THE BANGS (!) and DOTS (.) PLACEMENT!!
Often the subform container is named after the subform. I rename these due to the confusion such naming creates by appending "container" to the end of the default name.
Dec 9 '15 #3
rd3Po
9
Thank you mbizup. It didn't work either.
Dec 9 '15 #4
rd3Po
9
Hey zmbd. I'm an experienced Access user but inexperienced Access VBA user. I piece what I can into modules from what I find via Google searches and make them work for my databases. I give you that to say i'm not following your thread. Is your [frmQuery1_container] a sub-subform? In my instance [child3] is the given name of the subform I'm trying to get the row numbers to show up on.
Dec 9 '15 #5
zmbd
5,501 Expert Mod 4TB
Ok,
A few images
Parent form:



Subform Container:



actual subform --- NOTE the barely visible orange square outline just under the circle and around the actual child form:



So in this particular arrangement with a parent named [Form3] the reference to the child form named [frmTblPuke2] would be:
[Forms]![Form3]![frmTblPuke2_Container].[Form]

Now the default name for the subform-container when you create it is usually the same name as the form contained therein; however, this tends to cloud what the actual reference is when I am writing references to the child form so I tend to append the "_container" text to the SFC default name.

With a #Name error then I suspect that the name of the object used in the equation =RowNum() in the control's [Control Source] property is either misspelled or not the correct name of the object containing your child form.

With a #Error then There are no records or some other issue with one or more of the other bound controls or one or more of the calculated controls bound to the same underlying record-set is erring.
Attached Images
File Type: jpg 965116_ParentSelected.jpg (48.4 KB, 2386 views)
File Type: jpg 965116_SubFormContainerSelected.jpg (51.2 KB, 2213 views)
File Type: jpg 965116_SubFormSelected.jpg (45.5 KB, 2253 views)
Dec 9 '15 #6
zmbd
5,501 Expert Mod 4TB
... another question comes to mind with the #Name error...
Is the function RowNum() in a standard module or in the form's module?

If in the form's, then move to a standard module.
Dec 9 '15 #7
rd3Po
9
I changed the subform name to child1_container, tried again, and... no luck.

Main Form



Subform



Line No Field



All appear to adhere to what has been suggested. Could it be that the module is incorrect? Should RowNum(frm As Form) be written differently?

Thanks!
Attached Images
File Type: jpg frmShopFloorDisplay.jpg (47.6 KB, 2063 views)
File Type: jpg zfrmOpenOrders.jpg (47.6 KB, 2043 views)
File Type: jpg LineNoField.jpg (47.5 KB, 2017 views)
Dec 9 '15 #8
rd3Po
9
It's in a standard module zmbd

Attached Images
File Type: jpg RowNumModule.jpg (45.7 KB, 2212 views)
Dec 9 '15 #9
zmbd
5,501 Expert Mod 4TB
+ Sorry your images in post#8 do not show enough detail... You need to "zoom-in" on the property pane. :)

+ I used the function you published against the form I took screenshots in Post#6 using the reference in Post#6 as given for a control in the subform therein without errors; thus, I think your function is correct; however your reference must be off somehow...
Dec 9 '15 #10
rd3Po
9
Hopefully these show up better :) oh, and, how do you get the pics to show up on the thread (so you don't have to edit the thread again haha)

could the reference be wrong in the module?










Attached Images
File Type: png frmShopFloorDisplay2.png (9.0 KB, 2062 views)
File Type: jpg LineNoField2.jpg (48.0 KB, 2151 views)
File Type: png zfrmOpenOrders2.png (9.3 KB, 2067 views)
File Type: jpg RowNumModule2.jpg (59.9 KB, 2081 views)
Dec 9 '15 #11
zmbd
5,501 Expert Mod 4TB


Control Name and Function Name are the same.
I would start with changing the control name to something else - I would suspect that is the source of the #Name errors
Attached Images
File Type: jpg 965116_SubFormControlPrpts.jpg (20.3 KB, 2294 views)
Dec 10 '15 #12
NeoPa
32,556 Expert Mod 16PB
rD3Po:
oh, and, how do you get the pics to show up on the thread (so you don't have to edit the thread again haha)
Follow these steps in order :
  1. Formulate your post originally with all the attachments uploaded then post it.
  2. Open a text editor to formulate the extra commands used to show your pictures.
  3. For each attachment of the post :
    1. Copy its link (Right-click on the link and select Copy Link Location (or similar)).
    2. Paste the link into the text editor after any previous ones.
    3. Add before the new link - [IMGNOTHUMB]
    4. Add after the new link - [/IMGNOTHUMB]
  4. When all attachments have been handled copy the whole lot to your clipboard.
  5. Go back to the post you just posted and select edit.
  6. Go to the end of your original entry and then paste in your earlier work.
  7. Resubmit the post.
Dec 11 '15 #13
rd3Po
9
Wow, could it have been that easy?! Also lesson learned for future projects.

Thanks for your help zmbd!!!!!

Dec 11 '15 #14
zmbd
5,501 Expert Mod 4TB
Variable scope can cause interesting things to happen :-)

:)
-z
Dec 11 '15 #15

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

Similar topics

5
by: jaad | last post by:
Hello, I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta. When I...
2
by: dougancil | last post by:
I have a user who had deleted some records from a database today using Access 2010. They have an ID field that's autonumbered. They have No Duplicates allowed. When they created a new record today,...
4
by: jbrumbau | last post by:
Hello, In Access 2010/2007, how do you prevent users from flipping into design view from the ribbon? I do not want to hide the entire ribbon (DoCmd.ShowToolbar "Ribbon", acToolbarNo) or even the...
4
beacon
by: beacon | last post by:
Hi everybody, My title may not exactly describe my issue, so please forgive my lack of creativity today. I've got a database that was created in Access 2003 that I've opened in Access 2010. I...
2
by: shannonsims | last post by:
In an effort to digitize our personnel files, I am currently building an Access database that tracks stores employee information, to include admin documents, leave requests, training docs etc. After...
4
by: RedGoldPhoenix | last post by:
Hi I wish to migrate DDL from DB2 to ACCESS 2010 So I delete "CREATE DATABASE" , "CREATE TABLESPACE" change " FOR SBCS DATA NOT NULL," in " NOT NULL," Delete line which contains "SET CURRENT"...
1
by: jdks2006 | last post by:
I work with a company who is needing to use Access 2010 to receipt in checks for paid invoices. Our issue came when our auditor found we had duplicate receipt numbers using serial numbered receipt...
5
Seth Schrock
by: Seth Schrock | last post by:
I have created a navigation form in Access 2010 using the horizontal tabs, 2 levels style. This form is my startup form. In the top row, I have to options. Under each option are several sub-tabs...
1
by: KurtBergman | last post by:
The Access 2010 Navigation form has very little documentation. One issue is moving to a different Tab (subform) in data AddMode. The assumed method is DoCmd.BrowseTo...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.