Results 1 to 4 of 4

Thread: PASSING APARAMETER !!!! HELP !!!!

  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

    Can anybody help me please?

    Thanks.


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

    Post

    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?


  3. #3

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

    Post

    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.

  4. #4
    New Member
    Join Date
    Feb 2000
    Location
    London
    Posts
    2

    Post

    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

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