Results 1 to 20 of 20

Thread: I NEED YOUR HELP PLEASE !!!!

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    South-Africa
    Posts
    46

    Post

    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.


  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    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.


  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    South-Africa
    Posts
    46

    Post

    PLEASE HELP ME WITH THIS I CAN"T GET IT TO WORK....TRIED EVERYTHING.

  4. #4
    Lively Member
    Join Date
    Jan 2000
    Posts
    65

    Post

    try storing the textbox value in a
    variable and pass as argument..

    .contacts <VARNAME>

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    South-Africa
    Posts
    46

    Post

    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.


    [This message has been edited by Corne (edited 02-09-2000).]

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    South-Africa
    Posts
    46

    Post

    No Success yet.
    P L E A S E H E L P !!!!!!

  7. #7
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    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!'

  8. #8

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    South-Africa
    Posts
    46

    Post

    It fails at this line:
    .Contacts txtCust.Text ' My Parameter

    It gives me an error "Type mismatch"
    What must I do?

    Thanks.

  9. #9
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    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!'

  10. #10

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    South-Africa
    Posts
    46

    Post

    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.

  11. #11
    Member
    Join Date
    Jan 2000
    Location
    Singapore
    Posts
    59

    Post

    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

  12. #12

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    South-Africa
    Posts
    46

    Post

    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.

  13. #13

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    South-Africa
    Posts
    46

    Post


    Code:
     .Contacts txtCust.Text
    Parameter Problem.
    Check previous posts.
    PLEASE HELP

  14. #14
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303

    Post

    first off what is .Contacts is this you parameter. If its text you are passing it must be enclosed within single quotes
    'your text'


    ------------------
    Thanks in advance for any help provided.

  15. #15

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    South-Africa
    Posts
    46

    Post

    No success please help.

  16. #16

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    South-Africa
    Posts
    46

    Post

    Please help this is getting urgent now.

    Please refer to previous posts.

    Thanks.

  17. #17
    Junior Member
    Join Date
    Feb 2000
    Posts
    23

    Post

    Why not try this:

    .Contacts CInt(txtCust.Text)

    Only a suggestion.

    ------------------
    It is by will alone I set my mind in motion.

    [email protected]

  18. #18
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    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).]

  19. #19

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    South-Africa
    Posts
    46

    Post


  20. #20
    New Member
    Join Date
    Jun 1999
    Location
    Chelsea, MA, USA
    Posts
    2
    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
  •  



Click Here to Expand Forum to Full Width