Hello again and thanks for the responses.
The business is not interested in migrating this project into an SQL environment, so I'm stuck with Access. Orange, the table has 122 fields because each of these fields is a point of data for each part the business decides to sell. Those 122 fields are on a standard upload form that is imported into a mainframe environment. The argument can certainly be made that I should not be designing to suit one particular output format and I have been looking at ways to better handle the situation. However, this is the current situation. Again, novice here. I knew almost nothing about Access a month or two ago. I've already redone several components of this database as I find better ways to do them.
My data macros are now working quite well tracking the change events except for my long text fields. Apparently data macros will not work on long text/memo fields, so I have been trying to find a way in VBA to do it. It's easy for a singular change, but if a user copies/pastes across multiple records, I get the error:
Here is my After Update event:
Code:
Private Sub Product_Blurb_AfterUpdate()
Call LogChange("PARTS", "MODIFIED", Me.ID.Value, Me.Part_Number.Value, Me.ActiveControl.Name, Me.ActiveControl.OldValue, Me.ActiveControl.Value)
End Sub
Here is my function:
Code:
Function LogChange(TableChanged As String, ChangeType As String, ChangedID As String, ChangedName As String, FieldChanged As String, ChangedFrom As Variant, ChangedTo As Variant)
Dim User As String 'User that made the change
Dim strSQL As String 'SQL statement
Dim rs As Recordset 'Recordset
On Error GoTo ErrHandler 'On errors, go to the error handler
GetWindowsUserID 'Call the function to get the user's windows username
Set rs = CurrentDb.OpenRecordset("tbl_Users", dbOpenDynaset) 'Store the contents of tblUsers
rs.FindFirst "[Windows Username]='" & UserName & "'" 'Look for a matching user name in the record set
User = rs![Full Name] 'Get the user's full name
strSQL = "INSERT INTO tbl_ChangeLog " & " ([Table] ,[Action], [Change Date], [User], [Changed ID], [Changed Name], [Field Changed], [Changed From], [Changed To]) " & "VALUES (""" & TableChanged & """,""" & ChangeType & """,#" & Now() & "#,""" & User & """," & ChangedID & ",""" & ChangedName & """,""" & FieldChanged & """,""" & ChangedFrom & """,""" & ChangedTo & """);"
DoCmd.SetWarnings False 'Turn off the pop-up confirmation messages
DoCmd.RunSQL strSQL 'Run the SQL statement
DoCmd.SetWarnings True 'Turn the warnings back on
RunCommand acCmdSaveRecord 'Save the record into the table
Exit Function 'Exit the function
'Skip to here when an error has occurred
ErrHandler:
MsgBox Err.Description & vbNewLine & Err.Number, vbOKOnly, "Error"
End Function
This issue as I understand it is that Access has moved away from the subform as the active window. I haven't figured out how to handle that. I tried setfocus on the subform again with no luck. If anyone has any ideas how to solve this, it will be the end of all of my auditing requirements and I would be very grateful.