-
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
_____________________________________________
If my string is a value it works ok.I have also tried changing my parameters datatypes at the property pages.NO success.I hope i did it right.
Can anybody help me please?
Thanks.
-
Hi,
I *really* don't know what your program does but I think the problem's that you don't set your string to any var (I think you missed the "="). It should look something like this:
-
.Contacts.VALUE = txtCust.Text
-
Fox
------------------
[email protected]
...
Every program can be reduced to one instruction which doesn't work.
-
PLEASE HELP ME WITH THIS I CAN"T GET IT TO WORK....TRIED EVERYTHING.
:confused: :eek: :mad: :( :o
-
try storing the textbox value in a
variable and pass as argument..
.contacts <VARNAME>
-
I tried to store it as a variable but it will not work because I stored my parameter as a "?" in the sql statement(command) in my dataenvironment.
:D :confused:
[This message has been edited by Corne (edited 02-09-2000).]
-
No Success yet.
P L E A S E H E L P !!!!!!
:mad: :confused:
-
Give me the exact line where it fails. I think I have an idea but it depends on where it fails.
------------------
'cos Buzby says so!'
-
It fails at this line:
.Contacts txtCust.Text ' My Parameter
It gives me an error "Type mismatch"
What must I do? :confused:
Thanks.
-
I'm not sure if you need the equals sign or not but when you work with strings you usually have to wrap them in single quotes.
.Contacts "'" & txtCust.Text & "'"
Would this work?
Plus, I"m a little confused at this:
With DataEnvironment1
If .rsContacts.State = adStateOpen Then
.rsContacts.Close
End If
.Contacts txtCust.Text ' My Parameter
If .rsContacts.RecordCount > 0 Then
If you close .rsContacts, then reference it agian without setting it, is the
.Contacts txtCust.text
supposed to be .rsContacts? Is this statement supposed to set the contacts where it equals the txtCust.text? What control is the DataEnvironment1?
------------------
'cos Buzby says so!'
-
The dataenvironment comes with vb6.(Help for building reports.)
Check Carl Moore data base tutorials on building reports.I think it 6 or 7.
I tried your way already and it did not work.
THanks for your help.
:D
-
Hi,
Please check the following .(since it is a datatype mismatch)
1: First thing check your parameter datatype .May be that will be different from your front end datatype.
2: Please check the database field data type.
3: Please check whether you have mentioned the length of your parameter in the parameter tab.
4: Please check the parameter return type.
I hope after checking all these thing it should work.
Thanks
Karun
-
to karunakaran
I played around with the parameter properties but it did not work.
Can you maybe tell me how the parameter properties must look exactly if my parameter is a string.(etc VT_BSTR....)
Thaks.
:confused:
-
Code:
.Contacts txtCust.Text
Parameter Problem.
Check previous posts.
PLEASE HELP
:confused: :confused: :confused: :confused:
-
first off what is .Contacts is this you parameter. If its text you are passing it must be enclosed within single quotes
'your text'
:confused:
------------------
Thanks in advance for any help provided.
-
No success please help.
:confused:
-
Please help this is getting urgent now.
Please refer to previous posts.
Thanks.
-
Why not try this:
.Contacts CInt(txtCust.Text)
Only a suggestion.
------------------
It is by will alone I set my mind in motion.
[email protected]
-
Couple things:
1).
.Contacts txtCust.Text ' My Parameter
Contacts is a user-coded property, I think.
So check if data type of txtCust.Text matches passing parameter of property.
2).
If TextBox property MAX is set to something then it is Fixed Length String, wich is different Data Type than Variable length string. Check if this is the case.
By the way there are limitation of passing Fixed length Strings to the functions, subs and ....
3).
Some times Statament With does not work properly if before WEND you have other statamens using END keyword ( such as If_EndIF). It is getting worse with User-Defined Classes as Properties.
Hope it will help you, Let me know.
[This message has been edited by LG (edited 02-14-2000).]
-
:confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused: :confused:
-
first. check in your data environment the parameters option:
1. data_type adBSTR
2. Host_data_type String (VT_BSTR)
second, check the code.. dataenvironment.command txt.text
it has to work.. let me know