N
NikV
Is there a way to limit how many repeating sections you can have?
Franck Dauché said:Hi,
Here is an example:
create new IP project (with C#)
In the data source under myFields, Add 1 group called Test
Under Test add 1 repeating group: Test2
Under Test2, add 1 Text field test3
Now, drop Test on your form as a section
drop Test2 in that section as a repeating Table
Now, in your data source, select Test2, right-click and go to the
"Validation and Event Handlers" Tab.
select "OnBeforeChange" from the drop-down.
Click "Edit"
then insert that code the OnBeforeChange Event:
[InfoPathEventHandler(MatchPath="/my:myFields/my:Test/my:Test2",
EventType=InfoPathEventType.OnBeforeChange)]
public void Test2_OnBeforeChange(DataDOMEvent e)
{
IXMLDOMNode oNode = thisXDocument.DOM.selectSingleNode("//my:Test");
if (oNode != null)
{
if (oNode.childNodes.length > 5)
{
e.ReturnMessage = "Sorry can't have more than 3 entries!";
e.ReturnStatus = false;
}
}
}
It limits the number of textboxes to 3. You can start from there...
Hope that it helps.
Franck Dauché
NikV said:Franck;
I'm pretty new at this so please go into further detail. This is what I am
trying to accomplish:
I have template that will take data entry in from the user. The template is
designed to gather accomplishments for a department for the month. I have
several departments and each department has different set of categories that
have to be accomplished each month. I am catching these entries in by having
the user type text in textboxes. By using text boxes embedded in repeating
tables; is this the best way to go since I have to save all the inputted data
into MS SQL Database? Do you other recommendations on doing this?
Also can you go into detail steps on how to use the OnBeforeChange Event you
describe below. Thanks!
NikV said:Franck;
The first line in your response was to create a IP project "using C#". I've
never used C# before, I just start my projects in InfoPath. Does that make
sense?
Franck Dauché said:Hi,
Here is an example:
create new IP project (with C#)
In the data source under myFields, Add 1 group called Test
Under Test add 1 repeating group: Test2
Under Test2, add 1 Text field test3
Now, drop Test on your form as a section
drop Test2 in that section as a repeating Table
Now, in your data source, select Test2, right-click and go to the
"Validation and Event Handlers" Tab.
select "OnBeforeChange" from the drop-down.
Click "Edit"
then insert that code the OnBeforeChange Event:
[InfoPathEventHandler(MatchPath="/my:myFields/my:Test/my:Test2",
EventType=InfoPathEventType.OnBeforeChange)]
public void Test2_OnBeforeChange(DataDOMEvent e)
{
IXMLDOMNode oNode = thisXDocument.DOM.selectSingleNode("//my:Test");
if (oNode != null)
{
if (oNode.childNodes.length > 5)
{
e.ReturnMessage = "Sorry can't have more than 3 entries!";
e.ReturnStatus = false;
}
}
}
It limits the number of textboxes to 3. You can start from there...
Hope that it helps.
Franck Dauché
NikV said:Franck;
I'm pretty new at this so please go into further detail. This is what I am
trying to accomplish:
I have template that will take data entry in from the user. The template is
designed to gather accomplishments for a department for the month. I have
several departments and each department has different set of categories that
have to be accomplished each month. I am catching these entries in by having
the user type text in textboxes. By using text boxes embedded in repeating
tables; is this the best way to go since I have to save all the inputted data
into MS SQL Database? Do you other recommendations on doing this?
Also can you go into detail steps on how to use the OnBeforeChange Event you
describe below. Thanks!
:
Hi,
You can do it using code in the OnBeforeChange Event where you can count the
number of childNodes and you can cancel the Event if the Max was reached.
Franck Dauché
:
Is there a way to limit how many repeating sections you can have?
Franck Dauché said:Hi,
Here is an example:
create new IP project (with C#)
In the data source under myFields, Add 1 group called Test
Under Test add 1 repeating group: Test2
Under Test2, add 1 Text field test3
Now, drop Test on your form as a section
drop Test2 in that section as a repeating Table
Now, in your data source, select Test2, right-click and go to the
"Validation and Event Handlers" Tab.
select "OnBeforeChange" from the drop-down.
Click "Edit"
then insert that code the OnBeforeChange Event:
[InfoPathEventHandler(MatchPath="/my:myFields/my:Test/my:Test2",
EventType=InfoPathEventType.OnBeforeChange)]
public void Test2_OnBeforeChange(DataDOMEvent e)
{
IXMLDOMNode oNode = thisXDocument.DOM.selectSingleNode("//my:Test");
if (oNode != null)
{
if (oNode.childNodes.length > 5)
{
e.ReturnMessage = "Sorry can't have more than 3 entries!";
e.ReturnStatus = false;
}
}
}
It limits the number of textboxes to 3. You can start from there...
Hope that it helps.
Franck Dauché
NikV said:Franck;
I'm pretty new at this so please go into further detail. This is what I am
trying to accomplish:
I have template that will take data entry in from the user. The template is
designed to gather accomplishments for a department for the month. I have
several departments and each department has different set of categories that
have to be accomplished each month. I am catching these entries in by having
the user type text in textboxes. By using text boxes embedded in repeating
tables; is this the best way to go since I have to save all the inputted data
into MS SQL Database? Do you other recommendations on doing this?
Also can you go into detail steps on how to use the OnBeforeChange Event you
describe below. Thanks!
NikV said:Franck;
I am a beginner. In the first line you wrote create an IP Project from C#.
How do I do that?
Franck Dauché said:Hi,
Here is an example:
create new IP project (with C#)
In the data source under myFields, Add 1 group called Test
Under Test add 1 repeating group: Test2
Under Test2, add 1 Text field test3
Now, drop Test on your form as a section
drop Test2 in that section as a repeating Table
Now, in your data source, select Test2, right-click and go to the
"Validation and Event Handlers" Tab.
select "OnBeforeChange" from the drop-down.
Click "Edit"
then insert that code the OnBeforeChange Event:
[InfoPathEventHandler(MatchPath="/my:myFields/my:Test/my:Test2",
EventType=InfoPathEventType.OnBeforeChange)]
public void Test2_OnBeforeChange(DataDOMEvent e)
{
IXMLDOMNode oNode = thisXDocument.DOM.selectSingleNode("//my:Test");
if (oNode != null)
{
if (oNode.childNodes.length > 5)
{
e.ReturnMessage = "Sorry can't have more than 3 entries!";
e.ReturnStatus = false;
}
}
}
It limits the number of textboxes to 3. You can start from there...
Hope that it helps.
Franck Dauché
NikV said:Franck;
I'm pretty new at this so please go into further detail. This is what I am
trying to accomplish:
I have template that will take data entry in from the user. The template is
designed to gather accomplishments for a department for the month. I have
several departments and each department has different set of categories that
have to be accomplished each month. I am catching these entries in by having
the user type text in textboxes. By using text boxes embedded in repeating
tables; is this the best way to go since I have to save all the inputted data
into MS SQL Database? Do you other recommendations on doing this?
Also can you go into detail steps on how to use the OnBeforeChange Event you
describe below. Thanks!
:
Hi,
You can do it using code in the OnBeforeChange Event where you can count the
number of childNodes and you can cancel the Event if the Max was reached.
Franck Dauché
:
Is there a way to limit how many repeating sections you can have?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.