|
-
Feb 6th, 2000, 03:20 PM
#1
Thread Starter
Member
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.
-
Feb 6th, 2000, 03:32 PM
#2
PowerPoster
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.
-
Feb 7th, 2000, 10:31 PM
#3
Thread Starter
Member
-
Feb 8th, 2000, 12:27 PM
#4
Lively Member
try storing the textbox value in a
variable and pass as argument..
.contacts <VARNAME>
-
Feb 8th, 2000, 02:02 PM
#5
Thread Starter
Member
-
Feb 9th, 2000, 02:30 PM
#6
Thread Starter
Member
-
Feb 9th, 2000, 09:17 PM
#7
Hyperactive Member
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!'
-
Feb 9th, 2000, 09:26 PM
#8
Thread Starter
Member
It fails at this line:
.Contacts txtCust.Text ' My Parameter
It gives me an error "Type mismatch"
What must I do? 
Thanks.
-
Feb 9th, 2000, 09:39 PM
#9
Hyperactive Member
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!'
-
Feb 10th, 2000, 01:52 PM
#10
Thread Starter
Member
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.
-
Feb 10th, 2000, 02:19 PM
#11
Member
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
-
Feb 10th, 2000, 03:02 PM
#12
Thread Starter
Member
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.
-
Feb 10th, 2000, 08:46 PM
#13
Thread Starter
Member
-
Feb 10th, 2000, 09:07 PM
#14
-
Feb 13th, 2000, 01:31 PM
#15
Thread Starter
Member
No success please help.
-
Feb 13th, 2000, 02:44 PM
#16
Thread Starter
Member
Please help this is getting urgent now.
Please refer to previous posts.
Thanks.
-
Feb 13th, 2000, 04:06 PM
#17
Junior Member
Why not try this:
.Contacts CInt(txtCust.Text)
Only a suggestion.
------------------
It is by will alone I set my mind in motion.
[email protected]
-
Feb 13th, 2000, 09:13 PM
#18
Hyperactive Member
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).]
-
Feb 14th, 2000, 01:56 PM
#19
Thread Starter
Member
-
May 7th, 2000, 11:16 PM
#20
New Member
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
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
|