I have made a form (frmLogin) that is used as my homepage and has command buttons that take the user to other forms. However, I am trying to make the txt box on the frmLogin be able to filter by a date found in a table (tblDefaults) when the form is opened.
I am trying to pull the value from the tblDefaults form the column "DefDate". Whenever I open the form I get an error that says "Compile error: Invalid use of property." Here is the VBA code that I have written. Also when debugging it highlights ControlSource in my VBA code so that seems to be where the problem is but I can not figure out why.
VBA code:
Private Sub Form_Load()
Dim SQL As String
Dim db As Database
Dim rs As Recordset
strSQL = "SELECT tblDefaults.DefDate FROM tblDefaults WHERE (((tblDefaults.Default)='RetrieveDt'))"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL)
'Set Me.txtBS..Recordset= rs
Set Me.txtBS.ControlSource = rs!DefDate
Me.txtBS.Visible = True
Set rs = Nothing
Set db = Nothing
End Sub
Thanks
I am trying to pull the value from the tblDefaults form the column "DefDate". Whenever I open the form I get an error that says "Compile error: Invalid use of property." Here is the VBA code that I have written. Also when debugging it highlights ControlSource in my VBA code so that seems to be where the problem is but I can not figure out why.
VBA code:
Private Sub Form_Load()
Dim SQL As String
Dim db As Database
Dim rs As Recordset
strSQL = "SELECT tblDefaults.DefDate FROM tblDefaults WHERE (((tblDefaults.Default)='RetrieveDt'))"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL)
'Set Me.txtBS..Recordset= rs
Set Me.txtBS.ControlSource = rs!DefDate
Me.txtBS.Visible = True
Set rs = Nothing
Set db = Nothing
End Sub
Thanks