Type Mismatch error when using string from databas

Results 1 to 2 of 2

Thread: Type Mismatch error when using string from databas

  1. #1
    Ric Grosh Guest

    Default Type Mismatch error when using string from databas

    dim strTextToSearch<BR>strTextToSearch = rs("Comments") &#039get Comments field from database<BR><BR>dim objRegExp<BR>dim Matches<BR><BR>Set objRegExp = New RegExp<BR>objRegExp.Pattern = "guitars" &#039find guitars in string<BR>objRegExp.Global = True<BR>objRegExp.IgnoreCase = True<BR>Set Matches = objRegExp.Execute(strTextToSearch)<BR><BR>&#039the above line is what gives me the type mismatch error.<BR>&#039the error also occurs with Execute(rs("comments"))<BR>&#039if I set strTextToSearch to anything else like<BR>&#039strTextToSearch = "bla bla bla" then it works fine<BR>&#039I tested my variable with varType and it returned 8<BR>&#039for string so I don&#039t know what the problem is<BR><BR>-Ric<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Type Mismatch error when using string from dat

    Could be because you&#039re using a shorthand reference to the Recordset which usually evaluates to a field value, rather than actaully refering directly to the field value.<BR><BR>Try using:<BR><BR>strTextToSeach = rs.Fields("comments").Value<BR><BR>which is an explicit reference to the value of the field, rather than the field or recordset objects.<BR><BR>HTH<BR><BR>Dunc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts