Method or data member not found (1 Viewer)

lynsey2

Registered User.
Local time
Today, 20:28
Joined
Jun 18, 2002
Messages
439
i am reciving a message Method or Data Member not found!
and i dont know why? i have code that conversts a number into words e.g. 2 = two

Here is that:


Function GetNumberText(nmbr)

Dim nmbr_format As String
Dim nmbr_text As String
Dim thousands, hundreds, tens, units As Integer
Dim and_required As Boolean

Dim digits_array As Variant
digits_array = Array("?", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine")
Dim tens_array As Variant
tens_array = Array("?", "?", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety")
Dim teens_array As Variant
teens_array = Array("ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen")

' check number within range
If ((nmbr < 1) Or (nmbr > 9999)) Then
GetNumberText = "Error - Number out of range."
Exit Function
End If

' initialise variables
nmbr_text = ""
nmbr_format = ""

' format number with leading zeros and get various parts
nmbr_format = Format(nmbr, "0000")
thousands = CInt(Mid(nmbr_format, 1, 1))
hundreds = CInt(Mid(nmbr_format, 2, 1))
tens = CInt(Mid(nmbr_format, 3, 1))
units = CInt(Mid(nmbr_format, 4, 1))

' suss out if and required before building string
If (((thousands > 0) Or (hundreds > 0)) And ((tens > 0) Or (units > 0))) Then
and_required = True
Else
and_required = False
End If

' thousands
If thousands > 0 Then nmbr_text = nmbr_text & digits_array(thousands) & " thousand "
' hundreds
If hundreds > 0 Then nmbr_text = nmbr_text & digits_array(hundreds) & " hundred "
' and
If and_required Then nmbr_text = nmbr_text & "and "
' tens/units - note if tens = 1 then use teens list (and don't bother with units)
If tens = 1 Then
nmbr_text = nmbr_text & teens_array(units)
Else
If tens > 0 Then nmbr_text = nmbr_text & tens_array(tens) & " "
If units > 0 Then nmbr_text = nmbr_text & digits_array(units)
End If

' this is the text version of the number
GetNumberText = Trim(nmbr_text)

End Function

i have a form with 2 text boxes on it
one of them that you enter the number e.g. 2 and i want the other to automatically come up with the word two...i really dont want to have a button to do this! i made a button though to check that that would work and i get that error mesage?

in the code for the button i put

Private Sub Command122_Click()
NumberofDosesTxT.Value = GetNumberText(numberofdoses.Value)
End Sub

any clues would be great as i am stuck...i made a totaly different form to try this and it seems to work with that so i take it i am missing something somewhere!
 

Jon K

Registered User.
Local time
Today, 20:28
Joined
May 22, 2002
Messages
2,209
Your code worked fine from both the Click event of a button and the AfterUpdate event of text box numberofdoses. No error message.
 
R

Rich

Guest
I guess that you a Missing Reference, post back if you don't know how to correct it.
 

lynsey2

Registered User.
Local time
Today, 20:28
Joined
Jun 18, 2002
Messages
439
nope dont know how to fix it... i created just a form for that reason and it worked fine just dont know why it doesnt do it for the txt boxes on my acutal form that i need it to do it
 
R

Rich

Guest
Sorry misread, try your textbox control source =GetNumberText([numberofdoses]) assuming number of doses is the name of the field containg the numeric value
 

lynsey2

Registered User.
Local time
Today, 20:28
Joined
Jun 18, 2002
Messages
439
I thought about that too but 1. I have probems storing the values in the table if i put stuff in the control source bit and 2. the text box just comes up error?? if i do that!

im sorry i am a pain... i dont see how it can work in one form and not the one i need it to! Any other ideas would be sooo v.much appreciated as i have been wasting time on this for a while now! I just cant see whats up?:confused:
 

lynsey2

Registered User.
Local time
Today, 20:28
Joined
Jun 18, 2002
Messages
439
fixed it yey!:D
you know what i am afff ma heeed

NumberofDosesTxT.Value = GetNumberText(numberofdoses.Value)

SHOULD HAVE BEEN

NumberofDosesTxT.Value = GetNumberText(number_of_doses.Value)

SPOT THE DIFFERENCE

:p :rolleyes:
TA again!
See ya all soon

ockh well at least i gave s'bdy the code to change a number to txt if they didnt know it
 
R

Rich

Guest
You should Not store this text value in a table Lynsey, you can use the function anywhere in your db to obtain the text equivalent of the number.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 14:28
Joined
Feb 28, 2001
Messages
27,137
In general terms, the error message you report (Method or Data Member not found) is a simple case of having spelled a variable wrong AND having the "Declare All Variables" option checked in the Modules tab of the Tools>>Options dialog box.

Happens to me all the time, even though these days I'm a pretty good touch-typist. You learn to laugh at your typos, fix them, and go on about your business. Glad you found it!
 

lynsey2

Registered User.
Local time
Today, 20:28
Joined
Jun 18, 2002
Messages
439
thanx 4 your help you guys:D
made a note of that one rich ta!
see ya soon:D
 

Users who are viewing this thread

Top Bottom