Importing Data Fields From Database and Incrementing Values - InfoPath Dev
in

InfoPath Dev

Importing Data Fields From Database and Incrementing Values

Last post 03-24-2010 08:59 AM by nemadrias. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-19-2010 12:40 PM

    Importing Data Fields From Database and Incrementing Values

    I have a database which I am publishing data to from an Infopath form.  I'm able to input all of the data without a problem, and just added an auto-incrementing primary key (scan ID) in the database table.  I also want to show that ID (so it would be the max ID in the table +1) every time the form is opened to add a record to the database...

    SO...if the current records in the table were:

     Scan ID    Field 1    Field 2     Field 3

        1              blah       blah2     blah3

        2              blah       blah2     blah3

    Therefore, when the form is opened, I would need it to be:

     

    Scan ID:  3 ---> this field would autopopulate max(scanID) +1

    Then my input data.

     Once submitted, the data would be sent to the database....does this make sense?  Let me know if I can clarify.  Thanks!

  • 03-19-2010 01:59 PM In reply to

    Re: Importing Data Fields From Database and Incrementing Values

    There are a couple possible issues with this.

    1. Since the scanId column is auto-incrementing, I anticipate either SQL or InfoPath will complain if you try to set the value yourself
    2. The scanId is created when the data is submitted. If you set it when you open the form, you could have issues with mutiple rows having the same scanId. For example:
      • User A opens form, scanId set to max(scanId) + 1. Since the max is currently 2, User A gets a 3 for scanId
      • While User A has the form open, and before User A has submitted his form, User B opens the form, and scanId is set to .... 3, because max(scanId) in your database is still 2

    Is it really necessary for the user to know the scanId prior to the data being submitted to the database?

    Hilary Stoupa

  • 03-22-2010 07:39 AM In reply to

    Re: Importing Data Fields From Database and Incrementing Values

    It's probably not essential that the user knows the scanID before being submitted to the database...However, when I have the field in the database, it automatically looks for data from the form for a scanID...How would you go about submitting the data from the form, and not having the form expect a scanID, but auto-incrementing it?  Thanks for your help!

    Steve

  • 03-22-2010 05:43 PM In reply to

    Re: Importing Data Fields From Database and Incrementing Values

    This is a database bound form, right? Created from a database? And the scanId field is set up as an auto-incrementing identiy column? I haven't worked much with DB bound forms lately, but I if I recall correctly, this scenario should just work -- InfoPath knows the Id will come from SQL when the form is submitted, and doesn't worry about the field being blank. Are you having a different result?

    Hilary Stoupa

  • 03-24-2010 08:59 AM In reply to

    Re: Importing Data Fields From Database and Incrementing Values

    Got it now - had to remove the formula from the data field for scanID that was trying to increment max +1.  Thanks for your help it's looking good now!

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.