By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

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

P: 52
i'm using this for my list box:

Private Sub lstStock_Click()
'
rsMyRS.FindFirst "Stockcode=" & Str(lstStock.ItemData(lstStock.ListIndex))
txtCode.Text = rsMyRS!Stockcode
optVegi.Value = rsMyRS!Vegibox

And this for my Form load:

Do While Not rsMyRS.EOF
lstStock.AddItem rsMyRS!Stockcode
lstStock.ItemData(lstStock.NewIndex) = rsMyRS!Orderedon
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
Jan 10 '08 #1
Share this Question
Share on Google+
2 Replies


werks
100+
P: 220
i'm using this for my list box:

Private Sub lstStock_Click()
'
rsMyRS.FindFirst "Stockcode=" & Str(lstStock.ItemData(lstStock.ListIndex))
txtCode.Text = rsMyRS!Stockcode
optVegi.Value = rsMyRS!Vegibox

And this for my Form load:

Do While Not rsMyRS.EOF
lstStock.AddItem rsMyRS!Stockcode
lstStock.ItemData(lstStock.NewIndex) = rsMyRS!Orderedon
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.FindFirst "Stockcode=" & Str(lstStock.ItemData(lstStock.ListIndex.Text))


Better Than Yesterday (-.-)
Jan 10 '08 #2

Expert 5K+
P: 8,434
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...
Expand|Select|Wrap|Line Numbers
  1. rsMyRS.FindFirst "Stockcode = '" & lstStock.ItemData(lstStock.ListIndex) & "'"
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.
Jan 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.