Modules dont work any more?

L

Lana

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
 
D

Douglas J. Steele

"Dont work" doesn't give us much to go on.

What's the problem? Do you get an error message? If so, what is it? If you
don't get an error message, do you get anything? If so, what?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Lana said:
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
 
L

Lana

Sorry, I didnt explain correctly.

Module 1 is used in my report (writing the amount of money in words). When i
try to open the report it askes for parameter value "InWords". When i press
ok it opens the report with "#Error" instead of the supposed amount in words.

Module 2 is on my subform, used for numbering (1,2,3...) of entries on this
subform. Now instead of numbers i get "#Name?" message.

How can this be fixed?
Thank you.
Lana


Douglas J. Steele said:
"Dont work" doesn't give us much to go on.

What's the problem? Do you get an error message? If so, what is it? If you
don't get an error message, do you get anything? If so, what?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Lana said:
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
 
D

Douglas J. Steele

I just copied InWords into Access 2003, and had no problem with it at all
after correcting the line wrapping.

However, your RowNum has an error in it: the following statement appears to
terminate with an ampersand, which isn't allowed:

Debug.Print "RowNum() error " & Err.Number & " - " &

I suspect it's supposed to be

Debug.Print "RowNum() error " & Err.Number & " - " & _
Err.Description

One thing you might want to do for the first problem is check that your
References collection hasn't got messed up.

References problems can be caused by differences in either the location or
file version of certain files between the machine where the application was
developed, and where it's being run (or the file missing completely from the
target machine). Such differences are common when new software is installed.

Open any code module. Select Tools | References from the menu bar. Examine
all of the selected references.

If any of the selected references have "MISSING:" in front of them, unselect
them, and back out of the dialog. If you really need the reference(s) you
just unselected (you can tell by doing a Compile All Modules), go back in
and reselect them.

If none have "MISSING:", select an additional reference at random, back out
of the dialog, then go back in and unselect the reference you just added. If
that doesn't solve the problem, try to unselect as many of the selected
references as you can (Access may not let you unselect them all), back out
of the dialog, then go back in and reselect the references you just
unselected. (NOTE: write down what the references are before you delete
them, because they'll be in a different order when you go back in)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Lana said:
Sorry, I didnt explain correctly.

Module 1 is used in my report (writing the amount of money in words). When
i
try to open the report it askes for parameter value "InWords". When i
press
ok it opens the report with "#Error" instead of the supposed amount in
words.

Module 2 is on my subform, used for numbering (1,2,3...) of entries on
this
subform. Now instead of numbers i get "#Name?" message.

How can this be fixed?
Thank you.
Lana


Douglas J. Steele said:
"Dont work" doesn't give us much to go on.

What's the problem? Do you get an error message? If so, what is it? If
you
don't get an error message, do you get anything? If so, what?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Lana said:
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
 
L

Lana

Hi Douglas,

Our IT Specialist advised to re-install Windows and the Office, which we did
- and this morning the modules work fine again.

Except 1 thing: On the Form i have a textbox which is supposed to show same
value as on the subform, but is says "#Name?" instead. :(

The code is:
=(IIf(Child2.Form.RecordsetClone.RecordCount>0,Nz(Child2.Form.Text33),0))

What could be wrong here? Or do I have to re-install Windows again?

Thank you.
Lana


Douglas J. Steele said:
I just copied InWords into Access 2003, and had no problem with it at all
after correcting the line wrapping.

However, your RowNum has an error in it: the following statement appears to
terminate with an ampersand, which isn't allowed:

Debug.Print "RowNum() error " & Err.Number & " - " &

I suspect it's supposed to be

Debug.Print "RowNum() error " & Err.Number & " - " & _
Err.Description

One thing you might want to do for the first problem is check that your
References collection hasn't got messed up.

References problems can be caused by differences in either the location or
file version of certain files between the machine where the application was
developed, and where it's being run (or the file missing completely from the
target machine). Such differences are common when new software is installed.

Open any code module. Select Tools | References from the menu bar. Examine
all of the selected references.

If any of the selected references have "MISSING:" in front of them, unselect
them, and back out of the dialog. If you really need the reference(s) you
just unselected (you can tell by doing a Compile All Modules), go back in
and reselect them.

If none have "MISSING:", select an additional reference at random, back out
of the dialog, then go back in and unselect the reference you just added. If
that doesn't solve the problem, try to unselect as many of the selected
references as you can (Access may not let you unselect them all), back out
of the dialog, then go back in and reselect the references you just
unselected. (NOTE: write down what the references are before you delete
them, because they'll be in a different order when you go back in)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Lana said:
Sorry, I didnt explain correctly.

Module 1 is used in my report (writing the amount of money in words). When
i
try to open the report it askes for parameter value "InWords". When i
press
ok it opens the report with "#Error" instead of the supposed amount in
words.

Module 2 is on my subform, used for numbering (1,2,3...) of entries on
this
subform. Now instead of numbers i get "#Name?" message.

How can this be fixed?
Thank you.
Lana


Douglas J. Steele said:
"Dont work" doesn't give us much to go on.

What's the problem? Do you get an error message? If so, what is it? If
you
don't get an error message, do you get anything? If so, what?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



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
 
D

Douglas J. Steele

Assuming Child2 is the name of the control on the main form that holds the
subform, try using

=IIf(Me.Child2.Form.RecordsetClone.RecordCount>0,Nz(Me.Child2.Form.Text33),0)

If that doesn't work, check your references, as I advised previously.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top