Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-05-2002, 02:17 AM   #1
lynsey2
Registered User
 
lynsey2's Avatar
 
Join Date: Jun 2002
Location: Edinburgh
Posts: 439
Thanks: 0
Thanked 0 Times in 0 Posts
lynsey2
Method or data member not found

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!

lynsey2 is offline   Reply With Quote
Old 08-05-2002, 03:54 AM   #2
Jon K
Registered User
 
Join Date: May 2002
Posts: 2,209
Thanks: 0
Thanked 34 Times in 15 Posts
Jon K will become famous soon enough
Your code worked fine from both the Click event of a button and the AfterUpdate event of text box numberofdoses. No error message.
__________________
Access 2003, WinXP
Jon K is offline   Reply With Quote
Old 08-05-2002, 04:02 AM   #3
Rich
Guest
 
Posts: n/a
I guess that you a Missing Reference, post back if you don't know how to correct it.

  Reply With Quote
Old 08-05-2002, 04:24 AM   #4
lynsey2
Registered User
 
lynsey2's Avatar
 
Join Date: Jun 2002
Location: Edinburgh
Posts: 439
Thanks: 0
Thanked 0 Times in 0 Posts
lynsey2
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
lynsey2 is offline   Reply With Quote
Old 08-05-2002, 04:41 AM   #5
Rich
Guest
 
Posts: n/a
Sorry misread, try your textbox control source =GetNumberText([numberofdoses]) assuming number of doses is the name of the field containg the numeric value
  Reply With Quote
Old 08-05-2002, 05:08 AM   #6
lynsey2
Registered User
 
lynsey2's Avatar
 
Join Date: Jun 2002
Location: Edinburgh
Posts: 439
Thanks: 0
Thanked 0 Times in 0 Posts
lynsey2
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?
lynsey2 is offline   Reply With Quote
Old 08-05-2002, 06:00 AM   #7
lynsey2
Registered User
 
lynsey2's Avatar
 
Join Date: Jun 2002
Location: Edinburgh
Posts: 439
Thanks: 0
Thanked 0 Times in 0 Posts
lynsey2
fixed it yey!
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


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

lynsey2 is offline   Reply With Quote
Old 08-05-2002, 11:43 AM   #8
Rich
Guest
 
Posts: n/a
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.
  Reply With Quote
Old 08-06-2002, 04:41 AM   #9
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 14,392
Thanks: 88
Thanked 1,650 Times in 1,532 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
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!
The_Doc_Man is offline   Reply With Quote
Old 08-06-2002, 04:46 AM   #10
lynsey2
Registered User
 
lynsey2's Avatar
 
Join Date: Jun 2002
Location: Edinburgh
Posts: 439
Thanks: 0
Thanked 0 Times in 0 Posts
lynsey2
thanx 4 your help you guys
made a note of that one rich ta!
see ya soon

lynsey2 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 11:31 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World