Results 1 to 5 of 5

Thread: [RESOLVED] Wrong value in form

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    705

    Resolved [RESOLVED] Wrong value in form

    This started out, yesterday, as an interesting problem. Now it just sucks.
    I have a VB form with a group of text and combo boxes that are bound to fields in a datatable. One of the text boxes is bound to the PK, which is an integer field set to auto increment. I have the PK because I have found that saving and deleting records cannot be achieved without it.
    I am using a binding navigator which works as expected, except for the add new record button. The record gets added, but the value for the pk field is always -1 instead of the next increment (I am beginning to believe that it is excrement). I have tried everything I can think of, and a whole lot more, without coming up with a solution to this problem. I have used this before without any problems of this nature so I am totally at a loss as to why this is occurring. Any help would be appreciated.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Wrong value in form

    the value of the next key value isn't known until AFTER the data has actually been saved, when it gets generated by the database. What you're seeing is the provider on the CLIENT side trying to provide something because you asked it to. Since it doesn't know immediately what that next value is, it returns -1 initially. In fact, you can addnew multiple rows before sending it all off to the database. You would then see -1, -2, -3 and so on. Eventually the client side key will be replaced with what's in the database.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    705

    Re: Wrong value in form

    I thought that would be the case. However, hold it..... I just ran the form and added a record. After I saved it I checked the datatable in Access and the correct value was indeed in the record. So it would appear that while the record is getting the correct value the form/screen is not being update???? So what am I leaving out that would update the screen after the save. Actually, I have an idea that what I need is to run the table adapter to fill after the save is executed. If I am wrong give me a hint. Better still, just tell me what it takes.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Wrong value in form

    it takes a refreshing of the data from the database.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    705

    Re: Wrong value in form

    OK, thanks for the help.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width