A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Access 2000 Audit Trail - Combobox Question



 
 
Thread Tools Display Modes
  #1  
Old August 18th, 2005, 11:26 PM
Debra Farnham
external usenet poster
 
Posts: n/a
Default Access 2000 Audit Trail - Combobox Question

Hey All

I have developed an audit trail using the sample code provided by Microsoft
as follows:

Public Function WriteAudit(frm As Form, lngPermitNumber) As Boolean
On Error GoTo err_WriteAudit
Dim varcboInstalltype As Variant

Dim ctlC As Control
Dim strSQL As String
Dim bOK As Boolean

bOK = False

DoCmd.SetWarnings False


' For each control.
For Each ctlC In frm.Controls
If TypeOf ctlC Is TextBox Or TypeOf ctlC Is CheckBox Or TypeOf ctlC Is
ComboBox Then

If ctlC.Value ctlC.OldValue Or IsNull(ctlC.OldValue) Then
If Not IsNull(ctlC.Value) Then
strSQL = "INSERT INTO tblAudit (lngPermitNumber, FieldChanged,
FieldChangedFrom, FieldChangedTo, User, DateofHit ) " & _
" SELECT " & lngPermitNumber & " , " & _
"'" & ctlC.Name & "', " & _
"'" & ctlC.OldValue & "', " & _
"'" & ctlC.Value & "', " & _
"'" & GetUserName_TSB & "', " & _
"'" & Now & "'"
'Debug.Print strSQL
DoCmd.RunSQL strSQL
End If
End If
End If
Next ctlC

WriteAudit = bOK

exit_WriteAudit:
DoCmd.SetWarnings True
Exit Function

err_WriteAudit:
If Err.Number = 2427 Or Err.Number = 3251 Then

Exit Function
End If
MsgBox Err.Number, Err.Description
Resume exit_WriteAudit

End Function

My Question is this:

If the control is a combobox, I do not want to store in the table tblAudit
the actual value of the combobox as it is usually an autonumber. I want to
store the value/text that is displayed to the user instead (usually the
second column).

For example, is there any way of capturing the old value of column 2 of
cboSize and the new value of column 2 of cboSize or will I have to do a
lookup on cboSize once I have stored as variables the actual old and new
values of the combobox?

I am working with a form that has 16 comboxes. Dlookup seems like a "clunky"
solution but I can't think of another one.

Any assistance, as always, is greatly appreciated.

Debra


  #2  
Old August 19th, 2005, 01:05 AM
Debra Farnham
external usenet poster
 
Posts: n/a
Default

I have found a very simple solution .. that is ... to create a query to
create the report to show appropriate values rather than the autonumbers.

Thanks for taking the time to read this post.

Debra


"Debra Farnham" wrote in message
...
Hey All

I have developed an audit trail using the sample code provided by

Microsoft
as follows:

Public Function WriteAudit(frm As Form, lngPermitNumber) As Boolean
On Error GoTo err_WriteAudit
Dim varcboInstalltype As Variant

Dim ctlC As Control
Dim strSQL As String
Dim bOK As Boolean

bOK = False

DoCmd.SetWarnings False


' For each control.
For Each ctlC In frm.Controls
If TypeOf ctlC Is TextBox Or TypeOf ctlC Is CheckBox Or TypeOf ctlC Is
ComboBox Then

If ctlC.Value ctlC.OldValue Or IsNull(ctlC.OldValue) Then
If Not IsNull(ctlC.Value) Then
strSQL = "INSERT INTO tblAudit (lngPermitNumber, FieldChanged,
FieldChangedFrom, FieldChangedTo, User, DateofHit ) " & _
" SELECT " & lngPermitNumber & " , " & _
"'" & ctlC.Name & "', " & _
"'" & ctlC.OldValue & "', " & _
"'" & ctlC.Value & "', " & _
"'" & GetUserName_TSB & "', " & _
"'" & Now & "'"
'Debug.Print strSQL
DoCmd.RunSQL strSQL
End If
End If
End If
Next ctlC

WriteAudit = bOK

exit_WriteAudit:
DoCmd.SetWarnings True
Exit Function

err_WriteAudit:
If Err.Number = 2427 Or Err.Number = 3251 Then

Exit Function
End If
MsgBox Err.Number, Err.Description
Resume exit_WriteAudit

End Function

My Question is this:

If the control is a combobox, I do not want to store in the table tblAudit
the actual value of the combobox as it is usually an autonumber. I want to
store the value/text that is displayed to the user instead (usually the
second column).

For example, is there any way of capturing the old value of column 2 of
cboSize and the new value of column 2 of cboSize or will I have to do a
lookup on cboSize once I have stored as variables the actual old and new
values of the combobox?

I am working with a form that has 16 comboxes. Dlookup seems like a

"clunky"
solution but I can't think of another one.

Any assistance, as always, is greatly appreciated.

Debra




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ambiguous Name Error pm Using Forms 10 June 5th, 2005 09:19 PM
Why is a French Spellchecker a "required" update for English speak French Spellcheck Required? General Discussion 23 April 26th, 2005 01:17 AM
Can One Use Access 2003 on Access 2000 Databases? lbrinkman New Users 2 January 14th, 2005 11:13 PM
Access 2003 RK General Discussion 12 June 14th, 2004 10:16 AM
Problem running Access 2003 and Access 2000 apps on same machine. Rathtap General Discussion 3 June 13th, 2004 01:30 AM


All times are GMT +1. The time now is 01:29 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.