I am trying to update an adoc control programmatically, based on a variant
value retrieved from the Calendar control click event. If I hard code a
date
in my sql statement, records from an Access97 table are displayed in the
grid. However if I try to use the converted value from Calendar1.Value I
get the annoying "no value given for one or more required parameters"
message
Option Explicit
Private Sub Calendar1_Click()
Dim SQLVal As String
Dim pickedDate As Date
pickedDate = CStr(Calendar1.Value)
SQLVal = "SELECT Contacts.LastName, Contacts.FirstName, " & _
"Events.[Sched Date], Events.[Sched Time], Events.Comments " & _
"FROM Contacts, Events WHERE Contacts.ContactID = Events.ContactID " & _
"AND (Events.[Sched Date] = '12/01/00') " NOTE: with the hardcoded string
the adoc refreshes and the grid gets updated
SQLVal = "SELECT Contacts.LastName, Contacts.FirstName, " & _
"Events.[Sched Date], Events.[Sched Time], Events.Comments " & _
"FROM Contacts, Events WHERE Contacts.ContactID = Events.ContactID " & _
"AND (Events.[Sched Date] = pickedDate) " NOTE: passing the converted
calendar1.value causes the annoying "no value given for one or more
required parameters" message even though the pickedDate exists in the
database.
MsgBox SQLVal
Form1.Adodc1.RecordSource = SQLVal
Form1.Adodc1.Refresh
Set Form1.DataGrid1.DataSource = Adodc1
End Sub