M
MaryAnn
thanks for reading - here's my code. New problem here is
that anytime I use the date range, it errors. It also is
adding parameters together. Any help is appreciated.
Again, thank you so much!
(e-mail address removed)
Option Compare Database
Option Explicit
Private Sub cmdRunQuery_Click()
Dim MyDatabase As Database
Dim MyQueryDef As QueryDef
Dim rs As Recordset
Dim where As Variant
Set MyDatabase = CurrentDb()
If ObjectExists("Queries", "qryDynamic_QBF") = True
Then
MyDatabase.QueryDefs.Delete "qryDynamic_QBF"
MyDatabase.QueryDefs.Refresh
End If
where = Null
where = where & " AND [Clock Number]= '" + Me!
[txtClock]
where = where & " AND [Last Name]= '" + Me!
[Text15]
where = where & " AND [Date of Hire] Between " &
Format(Me![txtStart], "\#m\/d\/yyyy\#") & " And " & Format
(Me![txtEnd], "\#m\/d\/yyyy\#")
where = where & " AND [Location]= '" + Me![Text12]
where = where & " AND [Title]= '" + Me![Combo23]
where = where & " AND [Union]= '" + Me![Combo27]
Set MyQueryDef = MyDatabase.CreateQueryDef
("qryDynamic_QBF", _
"Select * from EADDataForPhotos " & (" where " + Mid
(where, 6) & ";"))
Set Recordset = MyDatabase.OpenRecordset("Select *
from EADDataForPhotos " & (" where " + Mid(where, 6)
& ";"))
If Recordset.RecordCount = 0 Then
MsgBox "No Records were found"
Else
DoCmd.OpenQuery "qryDynamic_QBF"
DoCmd.OpenForm "Search Results"
Forms![Search Results].Requery
DoCmd.Close acQuery, "qryDynamic_QBF"
End If
End Sub
that anytime I use the date range, it errors. It also is
adding parameters together. Any help is appreciated.
Again, thank you so much!
(e-mail address removed)
Option Compare Database
Option Explicit
Private Sub cmdRunQuery_Click()
Dim MyDatabase As Database
Dim MyQueryDef As QueryDef
Dim rs As Recordset
Dim where As Variant
Set MyDatabase = CurrentDb()
If ObjectExists("Queries", "qryDynamic_QBF") = True
Then
MyDatabase.QueryDefs.Delete "qryDynamic_QBF"
MyDatabase.QueryDefs.Refresh
End If
where = Null
where = where & " AND [Clock Number]= '" + Me!
[txtClock]
where = where & " AND [Last Name]= '" + Me!
[Text15]
where = where & " AND [Date of Hire] Between " &
Format(Me![txtStart], "\#m\/d\/yyyy\#") & " And " & Format
(Me![txtEnd], "\#m\/d\/yyyy\#")
where = where & " AND [Location]= '" + Me![Text12]
where = where & " AND [Title]= '" + Me![Combo23]
where = where & " AND [Union]= '" + Me![Combo27]
Set MyQueryDef = MyDatabase.CreateQueryDef
("qryDynamic_QBF", _
"Select * from EADDataForPhotos " & (" where " + Mid
(where, 6) & ";"))
Set Recordset = MyDatabase.OpenRecordset("Select *
from EADDataForPhotos " & (" where " + Mid(where, 6)
& ";"))
If Recordset.RecordCount = 0 Then
MsgBox "No Records were found"
Else
DoCmd.OpenQuery "qryDynamic_QBF"
DoCmd.OpenForm "Search Results"
Forms![Search Results].Requery
DoCmd.Close acQuery, "qryDynamic_QBF"
End If
End Sub