![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
So, anyone have any suggestions? |
#3
| |||
| |||
|
|
Datasheet form bound to an updatable view. |
#4
| |||
| |||
|
|
On Sun, 13 Jun 2010 16:41:53 -0400, "AVG" NOSPAMagiamb (AT) newsgroup (DOT) nospam> wrote: Datasheet form bound to an updatable view. Banana has some fine suggestions. Dumb question. Does the same thing happen if you use a continuous form rather than a datasheet form? Tony |
#5
| |||
| |||
|
|
On 6/13/10 1:41 PM, AVG wrote: So, anyone have any suggestions? Considering that you've had an open case with MS, some of suggestions may already been tried but I want to make sure we covered all bases so we know what has been already tried and failed (and why). It has been said before that to avoid field-by-field comparsion, one would add a RowVersion column to the table (in older SQL Server, that's misleadingly known as Timestamp, which is not in fact a timestamp). Access will then compare only the RowVersion and thus avoid the problem of losing the pointer to the changed entry. Did you try that? If it did not address the problem, can you make use of SCOPE_IDENTITY()? You said there was no way of getting the ID back from SQL Server, which is strange as SCOPE_IDENTITY() should do that for you, but maybe I'm not fully understanding the problem here. Thirdly, you say the problem occurs when the user changes an edit prior to the saving the record. Do you have any VBA code that saves the record behind the scene or could it be in partial state? I would expect that SQL Server would never receive the edited rows until it was saved by Access/your VBA code and thus that issue should not occur. Finally, if all of above does not apply/won't fix your problem, the alternative to look at is to use ADO recordset and bind it to the form, set the form's UniqueTable property and see if that help Access focus on only one table. If that does not even work, then you may need to take a step further and manipulate the ReSyncCommand property so it look at only the identity column. However, I've yet to try that. HTH. |
#6
| ||||||
| ||||||
|
|
For brevity, I did leave out the fact that I collected all of my info by monitoring SQL Profiler |
|
and that prior to Access requesting the new record by using all of the entered fields, it first requests the record by 'PKfield IS NULL' - something else we all know won't return a record. That wasted round trip (and another) |
|
SCOPE_IDENTITY() - Since this is a bound form, I don't see how I could do that. Unless, I used a local table and constantly synchronized it with SQL Server. Again, a good bit of work as there are several places in the system using forms bound to views. |
|
It only includes fields where data is entered. Apparently, if data is entered in a field and then deleted prior to saving, Access still includes that field in it's query. |
|
ADO - I should have mentioned that the project is an accdb using ODBC, not an adp. Please correct if I am mistaken, but isn't binding to an ADO recordset limited to adp's. |
|
I wasn't familiar with the ReSyncCommand and UniqueTable, so just did a search and they seem to apply to adp's also. If a form can be bound to an ADO recordset in an accdb, can you point me to an example? |
#7
| ||||||
| ||||||
|
|
On 6/13/10 6:08 PM, AVG wrote: For brevity, I did leave out the fact that I collected all of my info by monitoring SQL Profiler I did ascribe as such in your original post. and that prior to Access requesting the new record by using all of the entered fields, it first requests the record by 'PKfield IS NULL' - something else we all know won't return a record. That wasted round trip (and another) That is really tangential but I want to say I can't remember seeing that before - typically, it asks for primary key to use for scrolling then does lazy fetching thereafter. Are you saying it's sending a IS NULL when user enters a new record? |
|
SCOPE_IDENTITY() - Since this is a bound form, I don't see how I could do that. Unless, I used a local table and constantly synchronized it with SQL Server. Again, a good bit of work as there are several places in the system using forms bound to views. Okay, I wasn't thinking clearly on how you were working with and can see why it won't have helped. Getting the ID would still need you to requery. I also assume you've tried Me.Refresh to see if it clear #Deleted, yes? |
|
It only includes fields where data is entered. Apparently, if data is entered in a field and then deleted prior to saving, Access still includes that field in it's query. Gotcha. I think that is the key to the puzzle. I assume that the INSERT INTO statement put in the NULL value, yes? I'm under the impression those fields are numeric and thus we can't just cheat our way by passing in a ZLS. Do you have any values that you can consider to be invalid or at least used in lieu of NULL? If that is the case, an option is to set all non-required fields to the default value and thus work around that problem. Is that an option for you? |
|
ADO - I should have mentioned that the project is an accdb using ODBC, not an adp. Please correct if I am mistaken, but isn't binding to an ADO recordset limited to adp's. No. You can use and in fact, mix ADO with DAO in a *db file. I typically use 95% DAO and 5% ADO - ADO can be quite helpful in exceptional case where DAO/ODBC doesn't satisfy the requirement. I wasn't familiar with the ReSyncCommand and UniqueTable, so just did a search and they seem to apply to adp's also. If a form can be bound to an ADO recordset in an accdb, can you point me to an example? Hmm. Unfortunately, the documentation are confusing on that point. Yes, it does seem to imply that it's a ADP-only feature but I can assure you, having used UniqueTable to great success in a *DB file, it's not. The only thing about those two properties is that it only works with an ADO recordset even though they're available when using DAO recordset (will throw an error obviously). For binding ADO to a Access form, take a look and see if this get you started: http://support.microsoft.com/kb/281998/en-us |
|
With UniqueTable, it's straightforward. After using the above KB article to guide you for the binding, after the line "Set Me.Recordset = <ADODB recordset>", put in this line: Me.UniqueTable = "<name of table that you are actually updating>" |
|
HTH. |
#8
| ||||
| ||||
|
|
Yes, after the 'insert', Access requests the new record using PkField IS NULL as the where clause. When nothing is returned, it then resorts to using all of the fields that had anything entered in them, even if the entry was deleted prior to the 'insert'. |
|
Some fields are numeric and some text. Using ZLS was one of the suggestions from MS. They suggested changing all non-required numeric fields to text and don't allow nulls. It is totally impractical. |
|
The view uses 'INSTEAD OF' triggers for insert, update and delete, however, the PK is an identity column in one of the tables. |
|
Just how does Access utilize UniqueTable? Would it still be applicable? |
#9
| |||
| |||
|
|
Thanks for the quick reply Tony. Hadn't thought of that, so just tried it - yes, the same thing happens. |
|
I'll address Banana's comments next. |
#10
| |||
| |||
|
|
Datasheet form bound to an updatable view. |
![]() |
| Thread Tools | |
| Display Modes | |
| |