SubForm - Current Record

cratediggah

New Member
Joined
Jan 11, 2006
Messages
16
I am writing an auditing trail for my database. I have a form, within this form is a SubForm that is modified by the user. The audit works great, using the code below - however, I need to record the ID (autonumber) for each change, as you can see I've tried several ways, however it always gives me "1" as the record number when using CurrentRecord. Any ideas?

...
If rs.RecordCount > 0 Then rs.MoveLast
With rs
.AddNew
rs!FormName = Screen.ActiveForm.Name
rs!ControlName = strCtl
rs!RecordID = Screen.ActiveForm.CurrentRecord
rs!DateChanged = Date
rs!TimeChanged = Time()
rs!PriorInfo = Screen.ActiveControl.OldValue
rs!NewInfo = Screen.ActiveControl.Value
rs!CurrentUser = fOSUserName
.Update
End With
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
If you are running the audit code from the subform, try

rs!RecordID = Me.TheIDFieldForTheSubform 'change to suit

If you are running it from the main form, you need to reference the subform first:

rs!RecordID = MySubform.Form!TheIDFieldForTheSubform 'change to suit

Denis
 

Forum statistics

Threads
1,171,686
Messages
5,876,890
Members
433,217
Latest member
Muhammad Tanzeel Ur Rehma

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top