+1  A: 

Is the form in question bound to a datasource? This is the most common way that Access would be used, and if it were you probbaly wouldn't need to update via SQL.

Form_BeforeUpdate() is usually used when a form is bound to a datasource. You wouldn't normally use this event to determine if controls' values have changed and need writing back to the DB...

Mitch Wheat
Yes I am only using MSAccess as a front end -- all data is stored on a SQL Server database. What would you suggest I do in this situation?
Andrew G. Johnson
Also I am using ODBC to connect to the database if that wasn't already apparent...
Andrew G. Johnson
If the form and its controls are bound to a datasource (which is in term a query based on your linked tables), you probably don't need to write any code (unless you want to intercept and chnage values before writing) in order to save changed info...
Mitch Wheat
You're saying I should use a trigger I assume. I originally went down that path but decided against it as I need to log the active directory username of the person making the change (return value of ThisUserName()) and couldn't do that via a trigger.
Andrew G. Johnson
What are you actually trying to achieve? Big picture wise...
Mitch Wheat
This is an admin module for a local festival. If changes are made to performers,shows,etc the head admin would like to see who exactly made the change and what the change was -- a.k.a. old/new values
Andrew G. Johnson
If each user is connecting as thier logon Windows principle (rather than using a pooled connection string) you could use a trigger with TSQL's SUSER_NAME(). But if you're using a shared connection that's obviously no good...
Mitch Wheat
It is no good, believe me when I say I've walked down the same path you are walking now :)
Andrew G. Johnson
So you are using a pooled connection?
Mitch Wheat
It really makes no sense to not use unbound forms with ODBC data sources. You might as well program in plain VB if you're not using bound forms/controls.
David-W-Fenton
A: 

You run those querys against currentdb (wich I assume is the access-db) but are in fact using a SQL server database where you want the changes to happend?

Are those tables in the sql server linked to tables in the access-db or what method are you using?

Stefan
Yes they are linked tables to the SQL Server database.
Andrew G. Johnson
Are you sure that the links points to the database you think? I have many times made the mistake (when switching between different dev/deploy-servers) that looking in wrong database, thinking Im working on my local DB but actually running against another.
Stefan
No I am sure, not only is there only one database running this schema but even if I was connecting to the wrong one I would still not be having this error because of it.
Andrew G. Johnson
It "could" manifest itself like that if the "other" db has only those two records already and never being updated only shows them.. But OK, if you ruled that out then we have to check other possibilities
Stefan
A: 

Have you checked the table for broken triggers? It's a long shot, but some very very odd problems have been caused by bad/broken triggers before, and they're hard to understand before you notice the trigger...

Lasse V. Karlsen
No triggers on this entire database, but a valid suggestion.
Andrew G. Johnson
A: 

In your BeforeUpdate event, you should determine which (if any) controls have changed and only execute the write-to-changes table ONCE outside the loop over all the form's controls. Otherwise you are going to get so many change events! Why not create a copy of the target table, blah_history, without FKs and simply write the changed record to it?

Mitch Wheat
+1  A: 

If you can goto the specific SQL Server table (using Query Analyzer or Enterprise Mgr) & see whether it works as you expect. I am doubting that linked table in VBA might be showing you incorrect picture.

Edit: If you have SQL Profiler, see what is being executed there to confirm your doubt of the same query getting executed.

shahkalpesh
Wow, you're absolutely right. If I go right into SQL Server the data is correct. I actually laughed out loud when I saw this, now the question is: why doesn't it display properly in MS Access?
Andrew G. Johnson
Not sure about that part. But, I have observed this even when working inside Access. And, I thought of writing it after your reply of query being printed in Debug window correctly :)
shahkalpesh
A: 

Ah, you're using SQL Server too. I have had very good luck with using triggers to audit data changes behind Access. There are a couple of quirks, but linking the tables via ODBC using trusted authentication makes it very easy.

OK, so you can't or don't want to use triggers. When front-ending SQL with Access, I usually use ADO objects in my VBA code for this sort of thing. Linked tables with ODBC are great for bound forms, but nothing beats ADO for going directly to the SQL Server.

Would you like more information about linking the tables using trusted authentication or help with using ADO to do the work with SQL Server?

John Mo
A: 

Fixed by adding an auto-incrementing integer primary key column to the changes table.

Silly Access...

Andrew G. Johnson
No, silly Andrew G. Johnson for not knowing how to design an Access application. If you gave any thought to how ODBC has to work, you'd realize that a primary key is essential on all tables, and that a time stamp field is required to keep data in a bound form refreshed.
David-W-Fenton
Silly ODBC* -- why do you think its intelligent to have all these extra unneeded worries?
Andrew G. Johnson
A: 

I have to say the discussion around this question drives me crazy. With ODBC linked tables, you start with bound forms. There is simply no reason to be using pooled connections. If you are hostile to the Access implementation of how to do these things STOP USING ACCESS.

--
David W. Fenton
David Fenton Associates

David-W-Fenton