|
-
Mar 5th, 2015, 05:33 PM
#1
Thread Starter
Fanatic Member
[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.
-
Mar 5th, 2015, 05:50 PM
#2
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
-
Mar 5th, 2015, 06:03 PM
#3
Thread Starter
Fanatic Member
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.
-
Mar 5th, 2015, 06:26 PM
#4
Re: Wrong value in form
it takes a refreshing of the data from the database.
-tg
-
Mar 5th, 2015, 06:28 PM
#5
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|