Row Number on Continuous Form

sharpnova

Registered User.
Local time
Today, 10:58
Joined
Jun 9, 2011
Messages
69
I have an Access 2003 form (frmCompanies) with a continuous sub-form (frmDepartments)

I need a row number (sequential: 1, 2, 3, etc.) for each record displayed int he continuous form.

I have found an example of how to do this online but it is not working for me:

http://bytes.com/topic/net/insights/594455-row-numbers-alternate-colors-continuous-form[URL="http://bytes.com/topic/net/insights/594455-row-numbers-alternate-colors-continuous-form"]http://bytes.com/topic/net/insights/594455-row-numbers-alternate-colors-continuous-form[/URL]

I added a textbox to my frmDepartments and in the properties of that textbox:
Name = RowNum
ControlSource = =RowNum([Forms]![frmDepartments])

I then added the code in the linked example to a module.

But when the form loads, the textboxes for all the continuous records show only #Error

I have a feeling this is because my continuous form is a sub-form but I'm not sure. I can't get this working.

Update: I know it's because it's a sub-form because I just tested it for a regular continuous form that isn't a sub-form and it worked. So I guess my question is, how do I reference the form correctly now? I've tried =RowNum([Forms]![frmDepartments]), =RowNum([Forms]![frmCompanies]![frmDepartments]), and =RowNum([Forms]![frmCompanies].[frmDepartments]
 
Last edited:
I tried =RowNum(Forms!frmCompanies!frmDepartments.Form) and it worked.

Why?

I don't understand why putting Form at the end makes it work.

Update: Now it's not working that way. It did, then I copied it form my test forms into my main forms, it didn't work there. And it stopped working in the test forms as well.
 
Last edited:
why do you need a row number? row numbers are intinsically a non-database-concept.

eg what happens to the row number if you re-order the rows.
 
why do you need a row number? row numbers are intinsically a non-database-concept.

eg what happens to the row number if you re-order the rows.

I just want one for GUI reasons.

I'm trying to figure out why this example isn't working. But did.. then stopped working. worked on my test forms that were linked the same way.. and won't work on the original forms.
 
The textbox just displays #Name?

I don't know what this error means but it seems to me that it isn't even calling the function at all.
 
Resolved

I was referencing my subform by the name of the form instead of the name of the instance of the form as a subform. Aka, it may be frmDepartments, but when it was created as a subform on frmCompanies, that subform's name was Child3.

=RowNum([Forms]![frmCompanies]![Child3].Form) worked perfectly.

Also, I now understand why Form needs to be at the end. A subform is technically a control. You reference that control's form property and it treats it as an actual form.
 

Users who are viewing this thread

Back
Top Bottom