Populate Read-Only Textbox w/ AutoNumber on button click - InfoPath Dev
in

InfoPath Dev

Populate Read-Only Textbox w/ AutoNumber on button click

Last post 05-06-2008 09:13 AM by Paul Houtz. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 02-26-2008 08:42 AM

    Populate Read-Only Textbox w/ AutoNumber on button click

    Newbie to InfoPath here!!!!!! 

    I have an InfoPath form, and when the user clicks a button, we'd like to populate the textbox with a sequential autonumber, and it will be prefixed by a determined string....say "ABC".

    So, the first person to click the button will get the textbox populated with the value "ABC-000001", and the second person "ABC-000002", etc.

    I don't really know the best way to handle this, but am thinking an Access database is the best.

    On the button click event, I could insert a record (so I can now have a new ID) and populate a "holder" field of a datetime stamp, then after the insert statement do a select for the max ID ordered descending limit 1.

    What I don't know is how to do:

    1.  The actual insert into the Access DB

    2.  How to turn around and do the select / execute scalar for MAX ID DESC limit 1

    I have setup the connection to the Access DB in the codebehind for the InfoPath form.

    Thanks for the help!

  • 02-26-2008 11:09 AM In reply to

    Re: Populate Read-Only Textbox w/ AutoNumber on button click

    Typically you would generate this on submit to SQL or Access.

    Or create a list and have a flag field to mark it taken.  Are you identifying each user? You could link them to the ID they just chose or possibly with a time stamp.

    The big issue is uniqueness and when multiple forms are open making sure they don't get duped.

    One issue with the presubmit is that if the user abandons the form you numeration is not sequential, if that is an issue.

    Are you going to use InfoPath data connections or do things in code?

    I use our web services data connections so this is all built in to uniquely ID each document upon submit and the submit data connection returns the assigned number.

    Depending on what code you are using you should be bale to find the syntax to insert and query. I think with the command function you can actually create the Transact SQL statement to insert and select Max().

    InfoPath has a built in Max() function too.

  • 02-26-2008 11:20 AM In reply to

    Re: Populate Read-Only Textbox w/ AutoNumber on button click

    Hi, we basically inherited this InfoPath form from someone who'd already built the whole form w/o a database connection.

    What they wanted to do is just add an autoincrement to a textbox on the top of the form to help identify the form easier.

    Since I can't really get a data connection through the form, but could through the code-behind page, I'd like to do it in the code behind page.  I just don't know what "Imports" statement I need, and how to even set up / instantiate the connection, command, and scalar objects to call the database and return the results.

  • 02-26-2008 11:22 AM In reply to

    Re: Populate Read-Only Textbox w/ AutoNumber on button click

    Do you have SharePoint?

    Are you using Script or managed code in Visual Studio?

  • 02-26-2008 11:27 AM In reply to

    Re: Populate Read-Only Textbox w/ AutoNumber on button click

    Hello...yes we've got SharePoint.

    I was trying to use VB in the code behind.

  • 02-26-2008 12:27 PM In reply to

    Re: Populate Read-Only Textbox w/ AutoNumber on button click

    It may be easier to manage the list of ID's in SharePoint then.

    If you search here on CAML you can find out how to insert or update SP list items.

    IDNumber UserID Time

    Then you could have on open rules which would query the list and immediately insert the next incremented value, and then query to confirm the number and their userID.

    Then you should know they have reserved a number and can use it in the form uniquely.

  • 05-06-2008 09:13 AM In reply to

    Re: Populate Read-Only Textbox w/ AutoNumber on button click

    This solution maybe interesting to some.  I don't know much about coding and I was also not prepared to spend a lot of time building an autonumber.  I am using the ID field on a SharePoint List and updating a custom field after submitting the form.

    Take a look at my blog post here:  http://sharepoint2007only.blogspot.com/

     

     

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