Im using VB6 and Access 2003 - Data type mismatch error. Someone please help.?

im using VB6 and Access 2003

pdcon.Open

pdrs.Open "Select * from PatientsDetail Where RedgNum=" &

txtRedgNum.Text & "", pdcon, adOpenDynamic, adLockOptimistic

If Not (pdrs.BOF = True) Or Not (pdrs.EOF = True) Then

frmPatQ.Show

frmFindPat.Hide

Else

MsgBox " Blah Blah ", vbOKOnly + vbExclamation, "Validation"

Unload Me

frmFindPat.Show

End If

pdcon.Close

i am getting the error

2147217913(80040e07) Data type mismatch in criteria expression

Is there anyway i can correct this?

please help

thank you

Update:

The data type of RedgNum in the database is Text

4 Answers

Relevance
  • 1 decade ago
    Best Answer

    It doesn't look like you have quotes around RedgNum value. Try WHERE RedgNum='(single quote)"(double) & txtRedgNum.Text & "(double)'(single)"(double).

  • 3 years ago

    it rather is traditionally a hassle with your the region clause. you're announcing "the place 'some thing' equals 'some ingredient else'. those 2 values could desire to be at modern-day comparable, the two provided that they're a similar information type (e.G. each numbers), or they're close enogh for an implicit conversion. Double be sure your total '=' and be certain the two gadgets are the equivalent information sort.

  • 1 decade ago

    I think the problem is in this line:

    pdrs.Open "Select * from PatientsDetail Where RedgNum=" &

    txtRedgNum.Text & "", pdcon, adOpenDynamic, adLockOptimistic

    Is "RedgNum" numeric?

    txtRedgNum.Text is a string.

    You would need to convert "txtRedgNum" to a numeric value.

    Replace "txtRedgNum.Text" with "Val(txtRedgNum.Text)" and see if that helps.

    Also, you do not need the &""

    Instead of:

    txtRedgNum.Text & "", pdcon, adOpenDynamic, adLockOptimistic

    Just have it read:

    txtRedgNum.Text, pdcon, adOpenDynamic, adLockOptimistic

    or rather:

    Val(txtRedgNum.Text), pdcon, adOpenDynamic, adLockOptimistic

    Good luck.

  • 1 decade ago

    Looks like RedgNum in the select statement is numeric

    and your comparing it to txtRedgNum which is text

    convert txtRedgNum.Text to a numeric value

Still have questions? Get your answers by asking now.