PDA

View Full Version : Invalid oudside procedure


vasu_43
May 11, 2007, 11:20 PM
I want to creat data report in run time give specific date criteria while run code below gives arror message "invalid oudside procedure and highlighting on the ""Provider=Microsoft.Jet.OLEDB.4.0;"

Private Sub DTPicker1_Change()
Dim Mycon As New ADODB.Connection
Dim M2 As New ADODB.Recordset
Dim S1 As String

S1 = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & _
App.Path & "MainDB.mdb"
'M2.Open "select * from MainDB where booking_from>=#" & DTPicker1.Value & "# and InvDate <=# " & DTPicker2.Value & "# order by InvDate", Mycon, adOpenDynamic, adLockOptimistic
M2.Open "select * from MainDB where booking_from>=#" & DTPicker1.Value & "#, Mycon, adOpenDynamic, adLockOptimistic"
'Here I have used two dtpicker controls which consists of any two dates

Set DataReport2.DataSource = M2
DataReport2.WindowState = vbMaximized
DataReport2.Show vbModal
M2.Close
Mycon.Close
End Sub