G
Guest
Hi,
I was using Access 2002 before and now i changed to Access 2003.
Right after that I noticed that, for some reason, the 2 modules in my
database dont work any more.
Can anybody fix them for me please?
I didnt write them - so i havent got a slightest idea what could be wrong
with them. They worked fine just before..
Module 1:
Public Function InWords(AMT)
Dim TrinhBay, NhanRa, Nhom, Chu As String
Dim I, J As Byte, W, X, Y, Z As Double
Dim DonVi, HChuc, Khung
If AMT = 0 Then
TrinhBay = "None"
Else
DonVi = Array("None", "one", "two", "three", "four", "five", "six",
"seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen",
"fifteen", "sixteen", "seventeen", "eighteen", "nineteen")
HChuc = Array("None", "None", "twenty", "thirty", "fourty", "fifty",
"sixty", "seventy", "eighty", "ninety")
Khung = Array("None", "billion", "million", "thousand", "dong only")
NhanRa = Format(Abs(AMT), "############.00")
NhanRa = Right(Space(12) & NhanRa, 15)
For I = 1 To 4
Nhom = Mid(NhanRa, I * 3 - 2, 3)
If Nhom <> Space(3) Then
Select Case Nhom
Case "000"
If I = 4 And Abs(AMT) > 1 Then
Chu = "dong only"
Else
Chu = Space(0)
End If
Case Else
X = Val(Left(Nhom, 1))
Y = Val(Mid(Nhom, 2, 1))
Z = Val(Right(Nhom, 1))
W = Val(Right(Nhom, 2))
If X = 0 Then
Chu = Space(0)
Else
Chu = DonVi(X) & Space(1) & "hundred" & Space(1)
If W > 0 And W < 21 Then
Chu = Chu & "and" & Space(1)
End If
End If
If W < 20 And W > 0 Then
Chu = Chu & DonVi(W) & Space(1)
Else
If W >= 20 Then
Chu = Chu & HChuc(Y) & Space(1)
If Z > 0 Then
Chu = Chu & DonVi(Z) & Space(1)
End If
End If
End If
Chu = Chu & Khung(I) & Space(1)
End Select
TrinhBay = TrinhBay & Chu
End If
Next I
End If
InWords = UCase(Left(TrinhBay, 1)) & Mid(TrinhBay, 2)
End Function
Module 2:
'Copyright Stephen Lebans 1999
'May not be resold
'Please include my 1 line Copyright notice
'in your code if you use these functions
'I left a bunch of development code in here in case anyone decides to go
'down the same paths I did.
'Created by Stephen Lebans with help from Chris Bergmans
' Updated by Allen Browne Oct/2002
'Production version of GetLineNumberForm
'Works in Form or SubForm mode
'Set controlsource of unbound Text box to
'= RowNum([Form])
'Type exactly as above
Public Function RowNum(frm As Form) As Variant
On Error GoTo Err_RowNum
'Purpose: Numbering the rows on a form.
'Usage: Text box with ControlSource of: =RowNum([Form])
With frm.RecordsetClone
.Bookmark = frm.Bookmark
RowNum = .AbsolutePosition + 1
End With
Exit_RowNum:
Exit Function
Err_RowNum:
If Err.Number <> 3021& Then 'Ignore "No bookmark" at new row.
Debug.Print "RowNum() error " & Err.Number & " - " & Err.Description
End If
RowNum = Null
Resume Exit_RowNum
End Function
Thank you so much.
Lana
I was using Access 2002 before and now i changed to Access 2003.
Right after that I noticed that, for some reason, the 2 modules in my
database dont work any more.
Can anybody fix them for me please?
I didnt write them - so i havent got a slightest idea what could be wrong
with them. They worked fine just before..
Module 1:
Public Function InWords(AMT)
Dim TrinhBay, NhanRa, Nhom, Chu As String
Dim I, J As Byte, W, X, Y, Z As Double
Dim DonVi, HChuc, Khung
If AMT = 0 Then
TrinhBay = "None"
Else
DonVi = Array("None", "one", "two", "three", "four", "five", "six",
"seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen",
"fifteen", "sixteen", "seventeen", "eighteen", "nineteen")
HChuc = Array("None", "None", "twenty", "thirty", "fourty", "fifty",
"sixty", "seventy", "eighty", "ninety")
Khung = Array("None", "billion", "million", "thousand", "dong only")
NhanRa = Format(Abs(AMT), "############.00")
NhanRa = Right(Space(12) & NhanRa, 15)
For I = 1 To 4
Nhom = Mid(NhanRa, I * 3 - 2, 3)
If Nhom <> Space(3) Then
Select Case Nhom
Case "000"
If I = 4 And Abs(AMT) > 1 Then
Chu = "dong only"
Else
Chu = Space(0)
End If
Case Else
X = Val(Left(Nhom, 1))
Y = Val(Mid(Nhom, 2, 1))
Z = Val(Right(Nhom, 1))
W = Val(Right(Nhom, 2))
If X = 0 Then
Chu = Space(0)
Else
Chu = DonVi(X) & Space(1) & "hundred" & Space(1)
If W > 0 And W < 21 Then
Chu = Chu & "and" & Space(1)
End If
End If
If W < 20 And W > 0 Then
Chu = Chu & DonVi(W) & Space(1)
Else
If W >= 20 Then
Chu = Chu & HChuc(Y) & Space(1)
If Z > 0 Then
Chu = Chu & DonVi(Z) & Space(1)
End If
End If
End If
Chu = Chu & Khung(I) & Space(1)
End Select
TrinhBay = TrinhBay & Chu
End If
Next I
End If
InWords = UCase(Left(TrinhBay, 1)) & Mid(TrinhBay, 2)
End Function
Module 2:
'Copyright Stephen Lebans 1999
'May not be resold
'Please include my 1 line Copyright notice
'in your code if you use these functions
'I left a bunch of development code in here in case anyone decides to go
'down the same paths I did.
'Created by Stephen Lebans with help from Chris Bergmans
' Updated by Allen Browne Oct/2002
'Production version of GetLineNumberForm
'Works in Form or SubForm mode
'Set controlsource of unbound Text box to
'= RowNum([Form])
'Type exactly as above
Public Function RowNum(frm As Form) As Variant
On Error GoTo Err_RowNum
'Purpose: Numbering the rows on a form.
'Usage: Text box with ControlSource of: =RowNum([Form])
With frm.RecordsetClone
.Bookmark = frm.Bookmark
RowNum = .AbsolutePosition + 1
End With
Exit_RowNum:
Exit Function
Err_RowNum:
If Err.Number <> 3021& Then 'Ignore "No bookmark" at new row.
Debug.Print "RowNum() error " & Err.Number & " - " & Err.Description
End If
RowNum = Null
Resume Exit_RowNum
End Function
Thank you so much.
Lana