Hi guys,
I am working in Access 2003 andtrying to populate a form from an underlying query written on the fly. My code is as follows:
Private Sub cmdDefra_Form_Click()
Dim Cat As New ADOX.Catalog
Dim cmd As ADODB.Command
Dim sqlText As String
Set Cat.ActiveConnection = CurrentProject.Connection
Set cmd = New ADODB.Command
date1 = Forms!frmDefra_Select.txtDate1
date1 = Format(date1, "mm/dd/yy")
date2 = Forms!frmDefra_Select.txtDate2
date2 = Format(date2, "mm/dd/yy")
sqlText = "select * From qryWSF_Defra where date_of_purchase between " & "#" & date1 & "#" & _
" and " & "#" & date2 & "#"
cmd.CommandText = sqlText
Cat.Views.Append "qryDefra_Response", cmd
Set cmd = Nothing
Set Cat = Nothing
End Sub
This gives a MS error message on the line "Cat.Views.Append "qryDefra_Response", cmd" that throws me out of Access.
Any ideas?
Neil_W