Drop-Down List Box changing values on save - InfoPath Dev
in

InfoPath Dev

Drop-Down List Box changing values on save

Last post 03-17-2010 09:32 AM by Joemanc. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-15-2010 01:55 PM

    Drop-Down List Box changing values on save

    I have a listbox linked to a SQL Data Connection. My value field is an ID field, tknum. My DisplayName field is FullName, which is an alias field calculated in the Data Connection as LAstName, + FirstName. When I make a selection, and then click Save, the value in the List Box changes to the tknum value of the person I selected. I have some managed code running behind the listbox on the Changed event, and had thought it might be because the Changed event is fired off a few times when Saving. However, I added some variables to make sure the Changed event only fires off once, and the ListBox value is still set to tknum on the Save.

    Is it because the ListBox can't handle the calculated FullName alias field? Or could it be something else?

    Edit: I tried some more things in the meantime, still no luck.

    I tried to switch to a ComboBox - no luck

    I tried to add a field FullName to my table that feeds the Data Connection. I removed the alias from the Data Connection, and filled in values in the FullName table, then re-did my data properties on the lookup on the form, and that did not work.

    I also made each field in my Main table I am saving too(the tknum value) and the lookup table that contains the tknum value have the same data type. No luck

    Removed the primary key from the lookup table. No luck

    I checked the Logic Inspector, nothing hidden. I even created a new form with only the fields I need, and I get the same behavior.

  • 03-16-2010 11:13 AM In reply to

    Re: Drop-Down List Box changing values on save

    Though I'm not a developer (so seeing your code wouldn't help much), others might be willing to troubleshoot your code, so you could post it if possible.

    One thing I could suggest is creating a SQL view that contains tknum and the calculated Full Name, and just query that. That is, do the concat in the SQL view instead of in the InfoPath form.

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 03-16-2010 12:55 PM In reply to

    Re: Drop-Down List Box changing values on save

    Ernesto,

    It's not the code. I've commented the code out and still experience the same behavior.

    I did try your idea of using a SQL view, but once again, the value of the listbox keeps changing as soon as I hit save. The correct value(tknum) is saved to the database. It almost seems like Infopath is trying to add the tknum value to the listbox. Very bizarre behavior that has me stumped. Thanks for your help.

    Joe

  • 03-16-2010 11:50 PM In reply to

    Re: Drop-Down List Box changing values on save

    check if there is some code in

    FormEvents_Save(object sender, SaveEventArgs e)

    this gets fired when form is saved

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 03-17-2010 09:32 AM In reply to

    Re: Drop-Down List Box changing values on save

    As I suspected, bizarre behavior must mean a bizarre reason why this was not working, and it was!

    My tknum field in the SQL table is defined as nvarchar(10), but the length of the field itself is really only 4. When this table is being populated nightly, the data comes in with the tknum, and then 6 spaces. ex: '0135      '

    When I removed the 6 trailing spaces from the tknum field, my drop down list box works correctly on the Infopath form. Moral of the story, always trim your strings!

    Joe

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