Parsing value from subform's recordsource in VBA ?

liamfitz

Registered User.
Local time
Today, 17:39
Joined
May 17, 2012
Messages
240
The following code, as you see, SHOULD store a Date field ( Referral_Date ) Data Type value in a variable 'dt'. However, I get the error message 'Invalid qualifier' on the last line ...
Code:
Private Sub Referral_Date_AfterUpdate()
Dim refid As String
Dim dt As Date
dt = Me.RecordSource.Fields("Referral_Date")

Any thoughts ? Thanks.
:confused:
 
I think you should be using:
dt = Me.ActiveControl
or:
dt = Me.Referral_Date
 
Yep, no need to use Me.Recordsource as Bob has shown. If the field is bound to a control on the form and the control name is the same as the field name, you can use

dt = Me.Referral_Date

if the name of the control is different (say txtReferral_Date) than the field name

dt = Me.txtReferral_Date
or
dt = Me!Referral_Date ' which in this case would refer to the field and not the control.

or if the field is not bound to a control on the form but is in the recordsource

dt = Me!Referral_Date
 

Users who are viewing this thread

Back
Top Bottom