I've googled and searched and I'm ready to give up. I never thought it would be this tough.
All I want is to click a button to fire a query and have the result end up in a textbox. If the project wasn't going to build on itself and grow, I would look into Dlookup and such, I can't seem to find out if it's easier that way or not. Anyway, here is the code. Please tell me what the heck I'm doing wrong. All I get is Data Mismatch Errors. I've tried so many different things to change the datatypes, I can't even see straight.
Thanks,
Rog...
All I want is to click a button to fire a query and have the result end up in a textbox. If the project wasn't going to build on itself and grow, I would look into Dlookup and such, I can't seem to find out if it's easier that way or not. Anyway, here is the code. Please tell me what the heck I'm doing wrong. All I get is Data Mismatch Errors. I've tried so many different things to change the datatypes, I can't even see straight.
Thanks,
Rog...
Code:
Private Sub BTNSetup_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim SUSQL As String
Set db = CurrentDb
SUSQL = "SELECT DISTINCTROW Sum(PTQ_VSMP2_Breakdown.REGHRS) " & _
"FROM PTQ_VSMP2_Breakdown " & _
"WHERE (((PTQ_VSMP2_Breakdown.WOTYPE)='SU') AND ((PTQ_VSMP2_Breakdown.COMPLETIONDATE) Between '" & StartDay & "' And '" & EndDay & "')) " & _
"GROUP BY PTQ_VSMP2_Breakdown.WOTYPE; "
Set rst = db.OpenRecordset(SUSQL)
While Not rst.EOF
Me.Text18.Value = CStr(rst.Fields(0))
rst.MoveNext
Wend
rst.Close
db.Close
Set db = Nothing
End Sub