Access to SQL Log Issue (1 Viewer)

Skupe

New member
Local time
Today, 10:34
Joined
Feb 9, 2021
Messages
6
I am trying to move my Access application over to SQL Server and have a problem with one table not updating. The code creates a simple log file of user actions in the program.
In Access I have a Module with the following code -
Public Sub Logit(Description As String, Optional Notes As String = "")

Dim UserID As Long
Dim db As Database
Dim rs As Recordset

'on error resume next
UserID = Nz(Forms!MainMenuF!txtUserID)
Set db = CurrentDb()
Set rs = db.OpenRecordset("LogT", dbOpenDynaset)
rs.AddNew
rs!UserID = UserID
rs!Description = Description
If Notes <> "" Then rs!Notes = Notes
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing

End Sub

Using this I can just add Logit in any of my code and it write to the table who accessed something (form, control etc) and puts it in a table called LogT with a time stamp. It works great in Access but moving it over using the Microsoft Access to SQL Migration tool it no longer works and I'm stuck as to why and how to fix it. Below is a picture of the log file.
Logit.png


Any help on figuring this out would be appreciated
Steve
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:34
Joined
May 7, 2009
Messages
19,233
when you Linked the table back to ms access, did you choose the primary key?
can you manually add the record on the linked table?
 

Skupe

New member
Local time
Today, 10:34
Joined
Feb 9, 2021
Messages
6
The Primary key was already set in Access, I did not change anything about it. I was able to manually add a record into the table. All of my other tables seem to be working OK
 

Skupe

New member
Local time
Today, 10:34
Joined
Feb 9, 2021
Messages
6
I have a form that shows the LogT by running a Query. So while I could update the table manually, my query does not pick up the record. While I could just have the table in my form instead of the query, the table itself still does not update as it should
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:34
Joined
Feb 19, 2002
Messages
43,225
You need an additional argument if your table has an autonumber PK

(dbOpenDynaset, dbSeeChanges)
 

Skupe

New member
Local time
Today, 10:34
Joined
Feb 9, 2021
Messages
6
Thanks Pat worked great! Really appreciate the help.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:34
Joined
Feb 19, 2002
Messages
43,225
You're welcome. BTW, Since I either use SQL Server (or other RDBMS) from the start or convert later, I always make the app ODBC compliant from the outset to avoid conversion problems when (if) the time comes to convert. (dbOpenDynaset, dbSeeChanges) works with Jet/ACE even though they don't require it so I use it with all my recordset code.
 

Users who are viewing this thread

Top Bottom