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

Data mismatch error...please help!

P: 1
[PHP]lstSearchDoctor.ItemData(lstSearchDoctor.NewIndex) = mrsDoctorList!DoctorCode[/PHP]

Where DoctorCode as String

[PHP]lstSearchPatient.ItemData(lstSearchPatient.NewInde x) = mrsPatientList!PatientNum[/PHP]

Where PatientNum As Integer

Runtime error (13) data mismatch

Please help
Apr 12 '07 #1
Share this Question
Share on Google+
1 Reply


P: 47
[PHP]lstSearchDoctor.ItemData(lstSearchDoctor.NewIndex) = mrsDoctorList!DoctorCode[/PHP]

Where DoctorCode as String

[PHP]lstSearchPatient.ItemData(lstSearchPatient.NewInde x) = mrsPatientList!PatientNum[/PHP]

Where PatientNum As Integer

Runtime error (13) data mismatch

Please help
Hello,
You will get the runtime error. type mismatch.
I explain U in Details

Look .itemdata(index as integer) can only hold the Integer value as well as decimal value. i.e is the value should be numeric
like
Expand|Select|Wrap|Line Numbers
  1.   Combo1.AddItem "saikat"  'OK
  2.   Combo1.ItemData(Combo1.NewIndex) = 23 ' OK
  3.   Combo1.AddItem "kaushik"
  4.   Combo1.ItemData(Combo1.NewIndex) = 14'Ok
  5.  
Now when you use numeric value in string like "123" or "123.12" it will convert it
in integer
like 123 ,123 respectively
Expand|Select|Wrap|Line Numbers
  1.   Combo1.AddItem "saikat"
  2.   Combo1.ItemData(Combo1.NewIndex) = "23.23" 'no error 
  3.  
  4.   Combo1.AddItem "kaushik"
  5.   Combo1.ItemData(Combo1.NewIndex) = 14 'no error 
  6. ' the code works fine
  7.  
Now come to the main point when you try to assign alphanumeric value like "C123" in .itemdata then it will give you the runtime error.
Expand|Select|Wrap|Line Numbers
  1.   Combo1.AddItem "saikat"
  2.   Combo1.ItemData(Combo1.NewIndex) = "abc23" ' Error occur
  3.   Combo1.AddItem "kaushik"
  4.   Combo1.ItemData(Combo1.NewIndex) = 14 'no error
  5.  
So the conclusation is you can't store alpha-numeric value in itemdata.
I think u mention that the doctor code is string so it may contain code like"D123" Plz check it.
If u want to store the doctor code then use additems property to store it.
Hope I am cleared your confusion. good luck.
Apr 13 '07 #2

Post your reply

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