Execute VBA code on current record in MS Access form
I need to have code run on on the current record on a form. I have been out of VBA programming for a while so am pretty rusty. But here is my scenario;
My form is called frmContacts that contains a single record from my table CONTACTS. On this form is a button called MoveAttach that takes a file stored in the CONTACT table as an attachment data type and moves it to a local folder. I want this code to execute on the current record that the form is focused on (i.e., the CID value of of the record on the form).
Thanks in advance for your help.
Here is my code:
Private Sub MoveAttach_Click()
Dim db As Database
Dim rsContacts As Recordset2
Dim rsCAttach As Recordset2
Dim strCID As String
Set db = CurrentDb()
strCID = Me.CID.Value
' Instantiate the parent recordset.
Set rsContacts = db.OpenRecordset("CONTACTS")
' Instantiate the child recordset.
Set rsCAttach = rsContacts.Fields("CAttach").Value