Hi there,
I have 2 table:
- tblInvoice include Inv#, Type (Debit/Credit), InvoiceDate, ...
- tblCharge: ChargeCode, UP, Qty...
I have created a qry of these 2 table. It works properly. I added a Number spelling function to convert Total amt to word.
The error has happned when I change anything in tblInvoice. Every time I run the report, the report reports error 13 Type Mismatch. When I run debug, it point to Sodoc = Round(Sodoc, 0).
It's strange. This Number spelling function only spells the number in the report why is it impacted (by the change of tblInvoice record)?
Any one can help?
Thanks a lot
Quan
P/S: The following is the Number spelling function mentioned above.
=======
Option Compare Database
Public Solay(0 To 15) As String
Public Donvilay(0 To 4) As String
Private Sub Docchu()
Dim tp, Stp, ii
ii = 0: tp = Form_Form1.LabSo.Caption
Stp = InStr(tp, " ")
Do While Stp <> 0
Solay(ii) = Left(tp, Stp)
tp = Right(tp, Len(tp) - Stp)
1 Stp = InStr(tp, " ")
ii = ii + 1
Loop
End Sub
Private Sub Docdonvi()
Dim tp, Stp, ii
ii = 0: tp = Form_Form1.LabDonvi.Caption
Stp = InStr(tp, " ")
Do While Stp <> 0
Donvilay(ii) = Left(tp, Stp)
tp = Right(tp, Len(tp) - Stp)
Stp = InStr(tp, " ")
ii = ii + 1
Loop
End Sub
Public Function DocVND(Sodoc As String) As String
Call Docchu
Call Docdonvi
If Len(Sodoc) > 12 Then
DocVND = "So qua lon qua hang tram ty. Hay xem lai!"
Exit Function
End If
Sodoc = Round(Sodoc, 0)
Dim Cht As String
Dim fg0 As Boolean
Dim fg1 As Boolean
Dim So As String
Dim ch As String
Dim tp As String
Dim i As Byte
Dim dv
Dim chs
chs = Solay
dv = Donvilay
Do While Sodoc <> ""
Cht = ""
If Len(Sodoc) <> 0 Then
If (Len(Sodoc) >= 3) Then
So = Right(Sodoc, 3)
Else
So = Right(Sodoc, Len(Sodoc))
End If
Sodoc = Left(Sodoc, Len(Sodoc) - Len(So))
If Left(So, 1) = "0" And Mid(So, 2, 1) = "0" And Right(So, 1) = "0" Then
ch = ch
Else
If Len(So) = 3 Then
If Left(So, 1) <> " " Then
Cht = chs(Left(So, 1)) + chs(15)
End If
So = Right(So, 2)
End If
If Len(So) = 2 Then
If Left(So, 1) = "0" Then
If Right(So, 1) <> "0" Then
Cht = Cht + chs(11)
End If
fg0 = True
Else
If Left(So, 1) = "1" Then
Cht = Cht + chs(14)
Else
Cht = Cht + chs(Left(So, 1)) + chs(13)
fg1 = True
End If
End If
So = Right(So, 1)
End If
If Right(So, 1) <> 0 Then
If Left(So, 1) = "5" And Not fg0 Then
If Len(tp) = 1 Then
Cht = Cht + chs(4)
Else
Cht = Cht + chs(12)
End If
Else
If Left(So, 1) = 1 And Not (Not fg1 Or fg0) And Cht <> "" Then
Cht = Cht + chs(10)
Else
Cht = Cht + chs(Left(So, 1))
End If
End If
End If
ch = Cht + dv(i) + ch
End If
i = i + 1
End If
Loop
If Right(Trim(ch), 1) <> "." Then
ch = ch + dv(0)
End If
DocVND = UCase(Left(ch, 1)) & Mid(ch, 2)
End Function
I have 2 table:
- tblInvoice include Inv#, Type (Debit/Credit), InvoiceDate, ...
- tblCharge: ChargeCode, UP, Qty...
I have created a qry of these 2 table. It works properly. I added a Number spelling function to convert Total amt to word.
The error has happned when I change anything in tblInvoice. Every time I run the report, the report reports error 13 Type Mismatch. When I run debug, it point to Sodoc = Round(Sodoc, 0).
It's strange. This Number spelling function only spells the number in the report why is it impacted (by the change of tblInvoice record)?
Any one can help?
Thanks a lot
Quan
P/S: The following is the Number spelling function mentioned above.
=======
Option Compare Database
Public Solay(0 To 15) As String
Public Donvilay(0 To 4) As String
Private Sub Docchu()
Dim tp, Stp, ii
ii = 0: tp = Form_Form1.LabSo.Caption
Stp = InStr(tp, " ")
Do While Stp <> 0
Solay(ii) = Left(tp, Stp)
tp = Right(tp, Len(tp) - Stp)
1 Stp = InStr(tp, " ")
ii = ii + 1
Loop
End Sub
Private Sub Docdonvi()
Dim tp, Stp, ii
ii = 0: tp = Form_Form1.LabDonvi.Caption
Stp = InStr(tp, " ")
Do While Stp <> 0
Donvilay(ii) = Left(tp, Stp)
tp = Right(tp, Len(tp) - Stp)
Stp = InStr(tp, " ")
ii = ii + 1
Loop
End Sub
Public Function DocVND(Sodoc As String) As String
Call Docchu
Call Docdonvi
If Len(Sodoc) > 12 Then
DocVND = "So qua lon qua hang tram ty. Hay xem lai!"
Exit Function
End If
Sodoc = Round(Sodoc, 0)
Dim Cht As String
Dim fg0 As Boolean
Dim fg1 As Boolean
Dim So As String
Dim ch As String
Dim tp As String
Dim i As Byte
Dim dv
Dim chs
chs = Solay
dv = Donvilay
Do While Sodoc <> ""
Cht = ""
If Len(Sodoc) <> 0 Then
If (Len(Sodoc) >= 3) Then
So = Right(Sodoc, 3)
Else
So = Right(Sodoc, Len(Sodoc))
End If
Sodoc = Left(Sodoc, Len(Sodoc) - Len(So))
If Left(So, 1) = "0" And Mid(So, 2, 1) = "0" And Right(So, 1) = "0" Then
ch = ch
Else
If Len(So) = 3 Then
If Left(So, 1) <> " " Then
Cht = chs(Left(So, 1)) + chs(15)
End If
So = Right(So, 2)
End If
If Len(So) = 2 Then
If Left(So, 1) = "0" Then
If Right(So, 1) <> "0" Then
Cht = Cht + chs(11)
End If
fg0 = True
Else
If Left(So, 1) = "1" Then
Cht = Cht + chs(14)
Else
Cht = Cht + chs(Left(So, 1)) + chs(13)
fg1 = True
End If
End If
So = Right(So, 1)
End If
If Right(So, 1) <> 0 Then
If Left(So, 1) = "5" And Not fg0 Then
If Len(tp) = 1 Then
Cht = Cht + chs(4)
Else
Cht = Cht + chs(12)
End If
Else
If Left(So, 1) = 1 And Not (Not fg1 Or fg0) And Cht <> "" Then
Cht = Cht + chs(10)
Else
Cht = Cht + chs(Left(So, 1))
End If
End If
End If
ch = Cht + dv(i) + ch
End If
i = i + 1
End If
Loop
If Right(Trim(ch), 1) <> "." Then
ch = ch + dv(0)
End If
DocVND = UCase(Left(ch, 1)) & Mid(ch, 2)
End Function