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

Run-time error '13' Type mismatch

P: 4
Hello

I have difficulty in solving the run time error 13 type mismatch. I do not know how to solve it.
If i write this code "JOR_No.Value = Right(List225.ItemData(icount), 4) + 1". The error will appear.
If i remove " + 1" in the code, no error will shown and the whole code works normal.
Can anyone review my codes.

Please see attachment

Thanks
Attached Files
File Type: txt Run Time Error 13.txt (1.1 KB, 373 views)
Jul 31 '12 #1

✓ answered by zmbd

@Drahy
Glad to be of help... if this has answered your question would you please click on the [Choose as best Answer] button...

Thnx
Z

Share this Question
Share on Google+
3 Replies


zmbd
Expert Mod 5K+
P: 5,397
You are trying to numericaly add a value to a string.
http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
You will need to pull the information from the list, convert the string to a numeric and then do the math. Once you have the desired result, convert back to a string if needed.

-z

(OP's orignal code with some minor formatting)
Error happens at line 29
Expand|Select|Wrap|Line Numbers
  1. Private Sub Job_Class_n_AfterUpdate()
  2. Dim icount As Integer
  3. Dim strgsql As String
  4. If Job_Class_n.Value = "Electrical" Then
  5.   List238.Visible = False
  6.   List225.Visible = True
  7.   strgsql = "SELECT JOR.[JOR No], JOR.ID, " & _ 
  8.     "JOR.[Req'g Dep't], JOR.[Machine Ident'n], " & _
  9.     "JOR.DateR, JOR.[JOR Remarks], " & _
  10.     "JOR.[Job Class'n], " & _
  11.     "JOR.Category, JOR.[Description of Request], 
  12.     "JOR.Remarks " & _
  13.     "FROM JOR " & _
  14.     "WHERE (((JOR.[JOB Class'n]) = 'Electrical')) " & _
  15.     "ORDER BY JOR.[JOR No];"
  16.   With List225
  17.     .RowSourceType = "Table/Query"
  18.     .RowSource = strgsql
  19.     .ColumnCount = 10
  20.     .ColmnWidths = ".7in;.35in;.6in;.7in; " & _
  21.         ".65in;.65in;.6in;.6in;3in"
  22.     .ColumnHeads = True
  23.     .FontSize = 8
  24.     .Requery
  25.   End With
  26.   Label226.Caption = "Electrical"
  27.   For icount = 0 To (List225.ListCount - 1)
  28.     List225.Selected(icount) = True
  29.     JOR_No.Value = Right(List225.ItemData(icount), 4) + 1
  30.   Next icount
  31. End if
  32. End Sub
Jul 31 '12 #2

P: 4
Thanks for your advised
Its working.
I already converted the data in numerical value
before i add the data
I reformat my code block based on your suggestion
It is big help for me.

Thank you very much
Jul 31 '12 #3

zmbd
Expert Mod 5K+
P: 5,397
@Drahy
Glad to be of help... if this has answered your question would you please click on the [Choose as best Answer] button...

Thnx
Z
Aug 1 '12 #4

Post your reply

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