-
Why do i get a "type mismatch error" when i pass a "string" as a parameter.
Here is my code:
Private Sub cmdReport_Click()
'The If block closes the recordset if it was previously open before
'running the parameterized query.
With DataEnvironment1
If .rsContacts.State = adStateOpen Then
.rsContacts.Close
End If
' This passes in the value entered into the TextBox.
.Contacts "txtCust.Text" ' :( My Parameter
' This If block checks to determine if any records are returned
' by the parameter. Then it shows a report if records are returned.
' Or displays a Message Box if no records are returned.
If .rsContacts.RecordCount > 0 Then
' Degbug shows a number of records in the data source
Set rptContact.DataSource = DataEnvironment1
rptContact.Show
Else
MsgBox "No Titles found" & txtCust.Text
End If
End With
End Sub
Can anybody help me please?
Thanks. :)
-
first, kill the " around the text reference-
.Contacts "txtCust.Text" 'My Parameter
make it:
.Contacts txtCust.Text
you are sending in the string txtCust.text.
Now, .Contacts - what is this?
IS it supposed to be .rsContacts?
If so, what are you doing with it since you close it above. Are you trying to open it using the txtCust.text as the paramater?
-
OK I killed the " around my parameters.(Still no success)
The .Contacts must be right because when i change my parameter to a value the code works quite well.
So what must I do to get rid of the error "type mismatch" when i pass a string as a parameter.
Any help will be appreciated.
Thanks. :)
-
Have you checked in the dataenvironment to see if the the expected parameter is a string?
As a long shot try dimming a var as string and set the contents of the text box to the string and pass in the string.
Karl