|
-
Jul 19th, 2000, 03:13 PM
#1
Thread Starter
New Member
Hy all, I am having a difficult time with this code:Private Sub cmdFind_Click()
Dim db As Database
Dim rs As Recordset
Dim SQLString As String
Set db = OpenDatabase("c:\Nwind.mdb")
SQLString = "SELECT Orders.CustomerID, " & _
"Count(Orders.OrderID) " & _
"AS NoOfOrders From Orders GROUP " & _
"BY Orders.CustomerID " & _
"HAVING (((Orders.CustomerID)='" & _
txtCustID.Text & "'))"
Set rs = db.OpenRecordset(SQLString)
txtTotalNumber.Text = rs.Fields("NoOfOrders")
SQLString = "SELECT Orders.CustomerID, " & _
"Last(Orders.OrderDate) " & _
"AS LastOrderDate From Orders GROUP " & _
"BY Orders.CustomerID " & _
"HAVING (((Orders.CustomerID)='" & _
txtCustID.Text & "'))"
>>>>MISMATCH ERROR Set rs = db.OpenRecordset(SQLString)
txtLastDate.Text = rs.Fields("LastOrderDate")
txtLastDate.Text = Format(txtLastDate.Text, "Long Date")
rs.Close
db.Close
End Sub
Can anybody see anything wrong? I keep coming up with a mismatch error.
Thankyou for all your help
James ( the newbie )
-
Jul 20th, 2000, 01:05 AM
#2
Member
Apart from this line........
>>>>MISMATCH ERROR Set rs = db.OpenRecordset(SQLString)
which should be........
Set rs = db.OpenRecordset(SQLString)
I cannot see a lot else wrong.
-
Jul 20th, 2000, 10:04 AM
#3
Guru
It must be something in the SQL statement....Debug.Print the SQL statement before you do your Db.OpenRecordset
-
Jul 20th, 2000, 10:22 AM
#4
Fanatic Member
Check the values being entered into the table fields are the right type.
i.e.
you are not trying to put characters "abcdefg" into a filed that will only accept numeric "1234567"
Also try checking the format the date is being sent to the database.
Gary Lowe 
VB6 (Enterprise) SP5
ADO 2.6
SQL Server 7 SP3
OK I know my spelling and grammer is crap so don't quote me on it!
To err is human to take the P! is only natural !!
Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip

-
Jul 20th, 2000, 11:37 AM
#5
Thread Starter
New Member
Thankyou guys for the feedback. I will see if the data types are the same, however should it matter if you are only extracing values from a table? and not inserting?
BTW the line with the >>>>Mismatch Error was put there so I could show you were the error is taking place.
Thankyou for all your help!
James Stenerson
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
|