submit button unable to write into database table - InfoPath Dev Sign in | Join | Help in General InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » General » submit button unable to write into database table submit button unable to write into database table Last post 06-25-2010 01:48 AM by larryp7639. 15 replies. Page 1 of 2 (16 items) 1 2 Next > Sort Posts: Oldest to newest Newest to oldest Previous Next 07-10-2008 07:56 PM w2ngme Joined on 07-11-2008 Posts 2 submit button unable to write into database table Reply Contact I'm very new with info path. This the first time I'm using info path 2003 to create a form. I create a form for user to lodge services issue. I linked the form to a data source and bind each field in the form with its represent field on database (Microsoft access, table). When user submit the form, will send a copy of the form via e-mail to user and write/add it into the table. Problem 1: not sure how to add new records into the tableProblem 2: The copy of the form to user included the buttons form. Anyway after submitting the form the submit button is not included in the attachment? Or even better is there away to send just the contains of the form as e-mail contain rather then as an attachment? thanks. 07-10-2008 09:03 PM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact Hello and welcome! For problem 1, in order to submit to Access, you need to have based the form off the database when you initially designed it. If you did that, and the controls on the form are bound to the fields in the datafields group in the main data source, you should be able to submit to your table, which will add new records. For problem 2, you can add another field, a Boolean, called isSubmitted. You can add a rule to your submit button to set isSubmitted to true when the button is clicked. You can set conditional formatting on your button to hide if if isSubmitted is true. InfoPath 2007 has the option when you set up email submit to either attach the form or just include the contents, but I don't recall if that was available in 2003. Hope this helps, if it isn't clear enough or you need further help, let me know, okay? Hilary Stoupa Filed under: Access, conditional formatting 07-11-2008 01:09 AM In reply to w2ngme Joined on 07-11-2008 Posts 2 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact Thanks for the quick reply. Sorry I'm not very good at this. Do mean Problem 1: At the button properties i change the action to new record? I have only one button label as submit. When it's click it will write to the database and also send a copy of the form to the user as comfirmation. Problem 2: issubmitted an extra field in my DB OR a field i should declare in the function submit::OnClick(eventObj)?!? where would i fid this hide Am not to good at coding. any refrence. Thanks. 07-11-2008 07:41 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact Hello: No, I don't think anything you are doing will require code. First, let's add that field. Change your task pane to display the Data Source task pane Select the main data source Right click the root folder (probably myFields) Select Add Name the field isSubmitted (or another name, if you like) Change the Data type to True/false (boolean) Select OK Now you have another field that you can use to know whether the form has been submitted. Next, let's set some rules. Right click the button you are using for submitting Change the Action to Submit Select the Submit Options button Select Perform custom action using Rules Select the Rules button Select the Add button Give your Rule a meaningful name, like "Submit to database" Select Add Action ... Change the action to Submit using a data connection Make sure the data connection is your main data connection Select OK Select OK again This will set up the submission to the database. Next, we'll set a rule to set the value of isSubmitted. Select the Add button again to add another rule Give your rule a meaningful name, like "Set isSubmitted" Select Add Action ... Change the action to Set a field's value Select your isSubmitted field in the field area Type the word true in the value area Select OK Select OK again Finally, we add the rule for email submission. All of these actions could have been added to a single rule, but sometimes when you are new, it is easier to only have a single action in every rule. That way if something doesn't work the way you anticipate, you can deselect different rules to track down the problem. So, to submit our form to email: Select the Add button again to add another rule Give your rule a meaningful name, like "Send email" Select Add Action ... Change the action to Submit using a data connection Make sure the data connection is your email submit connection Select OK Select OK again, and once more to close that window For the grand finale, we'll set that conditional formatting on the button. In the Button Properties, select the Display tab Select the Conditional Formatting button Select the Add button In the first dropdown, select your isSubmitted field The second dropdown should say "Is equal to" In the third dropdown, select Type text Type in true Select the Hide this control checkbox Hilary Stoupa 06-18-2010 08:35 AM In reply to David Wipf Joined on 06-18-2010 Posts 6 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact Hi Hilary, in you second set of steps, step 10 says: Make sure the data connection is your main data connection. How do I do that? how do I set up a main data connection to write data to my SQL Server 2008 DB? The choices I am given when I try to set one up in the data connection wizard under "How do you want to submit your data?" are: To a Web service To a document library on a SharePoint site As an e-mail message To the hosting environment, such as an ASP.NET page or hosting application Well none of them sound correct, I tried the last one and there was no place to setup DB connection information. Do I need to write a web service that will handle the handshake of data to my SQL Server 2008 DB? Sounds combersome, why is it not built into InfoPath? What am I doing wrong? Thanks 06-18-2010 09:01 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact Hi, David: These steps were written out with the intent that form will have been designed off the database, in order to use InfoPath's built in submit to SQL or Access functionality. InfoPath does not provide the option to submit to database otherwise, I'm afraid. Hilary Stoupa 06-18-2010 09:08 AM In reply to David Wipf Joined on 06-18-2010 Posts 6 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact The form is designed off the database – at least it reads the data from the DB and displays the data on the form, but I cannot get it to submit to the DB. How do I do that? 06-18-2010 09:11 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact If you walk through your main data connection again, there will be a message in the last window of the wizard as to why you can't enable submit. It may be your table(s) have a data type that InfoPath doesn't care for, or no primary key ... So under Data Connections, select your main data connection and select Modify, and walk through the wizard again. Hilary Stoupa 06-18-2010 09:28 AM In reply to David Wipf Joined on 06-18-2010 Posts 6 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact Ok I am getting somewhere. I added a primary key of 3 fields. I was able to enable submit. when I put a record in with the exact 3 fields that already exist in the db it works as expected - it does not let me put in a dup record. But when I change the last of the 3 fields to be different - so now the primary 3 part key is unique - it still tells me that there is nothing to put in the db because it already exists even though it does not. Any ideas? thanks 06-18-2010 09:52 AM In reply to David Wipf Joined on 06-18-2010 Posts 6 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact Hi Hilary, Looks like there are 2 ways it should work. they way you list above and there is also an option under "Send for data to a single destination" of Database. but neither of the 2 methods really work. no mater what I type into my 3 fields that are part of my 3 part primary key InfoPath thinks the record already exists even though it does not. Does InfoPath have a multi-part primary key bug? Thanks David Wipf 06-18-2010 10:21 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact I'm a little bit confused, I'm afraid. What are you trying to do? Create a new record by modifying the key of an existing record? Hilary Stoupa 06-18-2010 10:36 AM In reply to David Wipf Joined on 06-18-2010 Posts 6 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact I have a table with 3 fields, every record in the DB should be unique, thus the 3 part primary key. I want the InfoPath form to allow the user to enter new records into the table. So they type in the 3 fields and hit the submit button. If the record already exists it should say so and not put the duplicate record into the DB. If the record does not exist it should add it to the table in the DB. No matter how I set it up InfoPath thinks the record already exists even though it does not. 06-18-2010 10:46 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact What happens if you try using the "new record" feature built into IP? That is, add a button that has the action of "new record"? Hilary Stoupa 06-18-2010 10:55 AM In reply to David Wipf Joined on 06-18-2010 Posts 6 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact I just changed the button from "Submit" to "New Record". there is noplace to hookup a db connection. I hit the button and it does nothing, does not complain, does nto say anything. And does not put the record into the DB. 06-18-2010 12:25 PM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: submit button unable to write into database table Mark as Not AnswerMark as Answer... Reply Contact A lot depends on how your form is set up. When you create a new blank form off a database, there will be a few buttons added to the blank form with some guidance text to help you get started. New Record will clear your fields bound to the datafields group in your main data source, so that you can fill them out and then use the Submit command to submit to the DB. Here's a link to a Microsoft Office online article that may help you. Hilary Stoupa Page 1 of 2 (16 items) 1 2 Next > Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Problem 1: not sure how to add new records into the table
thanks.
Hello and welcome!
For problem 1, in order to submit to Access, you need to have based the form off the database when you initially designed it. If you did that, and the controls on the form are bound to the fields in the datafields group in the main data source, you should be able to submit to your table, which will add new records.
For problem 2, you can add another field, a Boolean, called isSubmitted. You can add a rule to your submit button to set isSubmitted to true when the button is clicked. You can set conditional formatting on your button to hide if if isSubmitted is true. InfoPath 2007 has the option when you set up email submit to either attach the form or just include the contents, but I don't recall if that was available in 2003.
Hope this helps, if it isn't clear enough or you need further help, let me know, okay?
Thanks for the quick reply.
Sorry I'm not very good at this. Do mean
Problem 1: At the button properties i change the action to new record? I have only one button label as submit. When it's click it will write to the database and also send a copy of the form to the user as comfirmation.
Problem 2: issubmitted an extra field in my DB OR a field i should declare in the function submit::OnClick(eventObj)?!? where would i fid this hide
Am not to good at coding. any refrence.
Thanks.
Hello:
No, I don't think anything you are doing will require code. First, let's add that field.
Now you have another field that you can use to know whether the form has been submitted. Next, let's set some rules.
This will set up the submission to the database. Next, we'll set a rule to set the value of isSubmitted.
Finally, we add the rule for email submission. All of these actions could have been added to a single rule, but sometimes when you are new, it is easier to only have a single action in every rule. That way if something doesn't work the way you anticipate, you can deselect different rules to track down the problem. So, to submit our form to email:
For the grand finale, we'll set that conditional formatting on the button.
Hi Hilary,
in you second set of steps, step 10 says: Make sure the data connection is your main data connection.
How do I do that? how do I set up a main data connection to write data to my SQL Server 2008 DB?
The choices I am given when I try to set one up in the data connection wizard under "How do you want to submit your data?" are:
To a Web service
To a document library on a SharePoint site
As an e-mail message
To the hosting environment, such as an ASP.NET page or hosting application
Well none of them sound correct, I tried the last one and there was no place to setup DB connection information. Do I need to write a web service that will handle the handshake of data to my SQL Server 2008 DB? Sounds combersome, why is it not built into InfoPath?
What am I doing wrong?
Thanks
Hi, David:
These steps were written out with the intent that form will have been designed off the database, in order to use InfoPath's built in submit to SQL or Access functionality. InfoPath does not provide the option to submit to database otherwise, I'm afraid.
If you walk through your main data connection again, there will be a message in the last window of the wizard as to why you can't enable submit. It may be your table(s) have a data type that InfoPath doesn't care for, or no primary key ... So under Data Connections, select your main data connection and select Modify, and walk through the wizard again.
Ok I am getting somewhere. I added a primary key of 3 fields. I was able to enable submit. when I put a record in with the exact 3 fields that already exist in the db it works as expected - it does not let me put in a dup record.
But when I change the last of the 3 fields to be different - so now the primary 3 part key is unique - it still tells me that there is nothing to put in the db because it already exists even though it does not.
Any ideas?
thanks
Looks like there are 2 ways it should work. they way you list above and there is also an option under "Send for data to a single destination" of Database.
but neither of the 2 methods really work. no mater what I type into my 3 fields that are part of my 3 part primary key InfoPath thinks the record already exists even though it does not.
Does InfoPath have a multi-part primary key bug?
David Wipf
I'm a little bit confused, I'm afraid. What are you trying to do? Create a new record by modifying the key of an existing record?
I have a table with 3 fields, every record in the DB should be unique, thus the 3 part primary key.
I want the InfoPath form to allow the user to enter new records into the table.
So they type in the 3 fields and hit the submit button.
If the record already exists it should say so and not put the duplicate record into the DB.
If the record does not exist it should add it to the table in the DB.
No matter how I set it up InfoPath thinks the record already exists even though it does not.
What happens if you try using the "new record" feature built into IP? That is, add a button that has the action of "new record"?
I just changed the button from "Submit" to "New Record". there is noplace to hookup a db connection.
I hit the button and it does nothing, does not complain, does nto say anything.
And does not put the record into the DB.
A lot depends on how your form is set up. When you create a new blank form off a database, there will be a few buttons added to the blank form with some guidance text to help you get started. New Record will clear your fields bound to the datafields group in your main data source, so that you can fill them out and then use the Submit command to submit to the DB. Here's a link to a Microsoft Office online article that may help you.