|
-
Apr 6th, 2000, 02:16 AM
#1
Thread Starter
Addicted Member
I receive the error: Too few parameters. Expected 2. when I run the below code. I have never written a parameter in VB can someone help me out with what is wrong with the below code?
Data1.RecordSource = "PARAMETERS [FROM DATE] DateTime [TO DATE] DateTime;"
Data1.RecordSource = "SELECT * from MASTER where DATE_OPENED between [FROM DATE] AND [TO DATE]"
-
Apr 6th, 2000, 03:10 AM
#2
Addicted Member
Data1.RecordSource = "PARAMETERS [FROM DATE] DateTime [TO DATE] DateTime;"
Data1.RecordSource = "SELECT * from MASTER where DATE_OPENED between [FROM DATE] AND [TO DATE]"
You will need to do something like this
"SELECT * FROM MASTER WHERE DATE_OPENED between " & [FROM DATE] & " AND " [TO DATE]"
-
Apr 6th, 2000, 04:33 AM
#3
Thread Starter
Addicted Member
This syntax does not seem to work in VB so if anyone could help out i would appreciate it; thanks!!!
-
Apr 6th, 2000, 05:08 AM
#4
Hyperactive Member
Hi, there.
I didn't figure out how to use Parameter object with Data control. But there is another way:
Code:
Dim sql As String
sql = "Select OrderId,CustomerId from orders where orderdate between " & _
Chr(35) & Text1 & Chr(35) & " and " & Chr(35) & Text2 & Chr(35) 'Chr(35) is #
Data1.RecordSource = sql
Data1.Refresh
Larisa
-
Apr 6th, 2000, 07:00 AM
#5
Hyperactive Member
OK. I found how to use Parameters. I use NorthWind db
Code:
Dim str As String
Dim qdf As QueryDef
str = "PARAMETERS [Beginning OrderDate] DateTime, " _
& "[Ending OrderDate] DateTime; SELECT * FROM Orders " & _
"WHERE (OrderDate Between[Beginning OrderDate] " _
& "And [Ending OrderDate]);"
Set qdf = Data1.Database.CreateQueryDef("", str)
qdf.Parameters![Beginning OrderDate] = CDate(Text1)
qdf.Parameters![Ending OrderDate] = CDate(Text2)
Set Data1.Recordset = qdf.OpenRecordset
Data1.Recordset.MoveLast
Data1.Recordset.Close
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|