Microsoft
Software
Hardware
Network
Question : Using a date varible in where clause of SQL
Below is code for using a date varible in a SQL where clause. The date is coming from form frm_timeadj field text0. If I hardcode the date it works, with code below, I get no records error.
Private Sub Command7_Click()
Dim qdate As Date
Dim ID As String
Dim rs As DAO.Recordset
Dim db As Database
Dim rs2 As DAO.Recordset
ID = Form_MainForm.Text37
qdate = Form_frm_TimeAdj.Text0
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT hours FROM Sub_op_Time WHERE time_date = " & qdate & " and act_num = 11 and act_type_num = 1")
Set rs2 = db.OpenRecordset("SELECT num_hours FROM Inspector_List WHERE user_ID = '" & ID & "'")
If Form_frm_TimeAdj.Text8 > rs2!num_hours Then
MsgBox "Exceeded maximum Straight Time Hours for Day"
Else
rs.Edit
rs!Hours = rs2!num_hours - Form_frm_TimeAdj.Text8
rs.Update
End If
rs.Close
rs2.Close
Set rs = Nothing
Set rs2 = Nothing
Set db = Nothing
End Sub
Answer : Using a date varible in where clause of SQL
Try this:
Set rs = db.OpenRecordset("SELECT hours FROM Sub_op_Time WHERE time_date = #" & qdate & "# and
Random Solutions
how to add two Dataset...
Windows XP SP2 Automatic Updates Service Will Not Start
SBS 2008/Exchange 2007 broken Autodiscover
Merge InfoPath Sections Containing Check Boxes
After Update event code
OSC 2007 R2, need to deploy a FQDN pool. not sure how to
How to restore Windows 7 Home Premium?
SystemDB and MDW questions
replace field value with another value using MS TSQL
There isn't enough memory to perform this operation