Type Mismatch Problem!!!!!HELP!!!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • THEAF
    New Member
    • Mar 2007
    • 52

    Type Mismatch Problem!!!!!HELP!!!!!

    i'm using this for my list box:

    Private Sub lstStock_Click( )
    '
    rsMyRS.FindFirs t "Stockcode= " & Str(lstStock.It emData(lstStock .ListIndex))
    txtCode.Text = rsMyRS!Stockcod e
    optVegi.Value = rsMyRS!Vegibox

    And this for my Form load:

    Do While Not rsMyRS.EOF
    lstStock.AddIte m rsMyRS!Stockcod e
    lstStock.ItemDa ta(lstStock.New Index) = rsMyRS!Orderedo n
    rsMyRS.MoveNext
    Loop

    The Italic line is the one where i get the type mismatch problem.
    i'v stated text in Access, and text on vb so where am i getting it wrong. Please help.

    ThAnK YoU
  • werks
    New Member
    • Dec 2007
    • 218

    #2
    Originally posted by THEAF
    i'm using this for my list box:

    Private Sub lstStock_Click( )
    '
    rsMyRS.FindFirs t "Stockcode= " & Str(lstStock.It emData(lstStock .ListIndex))
    txtCode.Text = rsMyRS!Stockcod e
    optVegi.Value = rsMyRS!Vegibox

    And this for my Form load:

    Do While Not rsMyRS.EOF
    lstStock.AddIte m rsMyRS!Stockcod e
    lstStock.ItemDa ta(lstStock.New Index) = rsMyRS!Orderedo n
    rsMyRS.MoveNext
    Loop

    The Italic line is the one where i get the type mismatch problem.
    i'v stated text in Access, and text on vb so where am i getting it wrong. Please help.

    ThAnK YoU
    Try adding .Text at the end

    rsMyRS.FindFirs t "Stockcode= " & Str(lstStock.It emData(lstStock .ListIndex.Text ))


    Better Than Yesterday (-.-)

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Actually, it's quite simple. If it's a text field in the database, you need to put quotes around the search value.

      I suggest trying...
      [CODE=vb]rsMyRS.FindFirs t "Stockcode = '" & lstStock.ItemDa ta(lstStock.Lis tIndex) & "'"[/CODE]Tip: I'm pretty sure you don't need to use the Str() function.

      And a general comment: Aren't you searching on the wrong field? I thought ItemData held "Orderedon" (whatever that is), not StockCode.
      Last edited by Killer42; Jan 11 '08, 01:56 AM.

      Comment

      Working...