Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / September 2005

Tip: Looking for answers? Try searching our database.

Auto-incrementing a field in a table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sumeetkbali@gmail.com - 23 Sep 2005 22:30 GMT
Hi,

I have a repeating table and I need to autoincrement one of the fields
whenever the user adds a new row. I have tried the
"count(../preceding-sibiling::*) + 1 " even though I don't exactly get
what it means when it says ../preceding-sibling. Please let me know if
anybody has an idea.

Thanks in advance

Sumeet
Andrew Watt [MVP - InfoPath] - 24 Sep 2005 11:19 GMT
>Hi,
>
[quoted text clipped - 7 lines]
>
>Sumeet

Sumeet,

If I correctly understand what you are doing then
count(../preceding-sibling::*)+1
should work.

The XPath formula .. selects parent nodes. The preceding-sibling::*
selects all preceding siblings of those parent nodes whatever the name
of those nodes. If you want the count to start at 1 then you add one
to the value that the count() function returns.

Andrew Watt
MVP - InfoPath
KingFu - 28 Sep 2005 15:39 GMT
Hi Andrew,

I've got a similar problem.  I have a form that contains questions/answers.  
On one of the questions, you could have multiple answers.  My HR Dept wants
me to label these answers as (if you were on question 12)
12 a.  
12 b.  
12 c.  
12 d.  etc...

I've tried the "count(../preceding-sibiling::*) + 1" and get an error --

The axis is not valid.
count(../-->preceding-sibiling<--::*) + 1

My data source looks similar to this:

myFields
  group1
      group2
         answer to question 12
         comments
I'm putting the expression box in group2 for the abc or 123 count of rows.

Does this make sense?  Can you help me out?
Bali - 28 Sep 2005 16:14 GMT
Hi,

I was getting the same error so what I did was make the formula just
count(preceding-sibling::*)+1 instead of
count(../preceding-sibling::*)+1.

If you click the edit x-path checkbox below it in the case of
count(preceding-sibling::*)+1 it shows it as
count(../preceding-sibling::*)+1. As Andrew explained thats what we
want but in case of count(../preceding-sibling::*)+1 is written in the
formula field and you click edit x-path then the formula appears as
count(../../preceding-sibling::*)+1.

I don't know how you would take care of the 12 a, 12 b stuff but the
auto numbering worked this way

Sumeet
KingFu - 28 Sep 2005 16:33 GMT
Thanks!  That fixed it.  At least I'll be able to do a 12.1, 12.2, 12.3
etc....  hopefully that will suffice, as I think the alphabet solution would
be very problematic.

Thanks again,

KingFu
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.