Beginner

aziz rasul

Active member
Local time
Today, 04:58
Joined
Jun 26, 2000
Messages
1,935
I have created a database with only one table and one module.
The table contains two fields, ID & Field1(this is a memo field). Field1 simply contains text and includes a 5-digit number at random within the text. The purpose of the module or code is to extract the 5-digit number in an unbound text box on a form based on the table. In the module I have copied and pasted the following function (which appeared on this forum recently): -

Function getnumbersFromMemo(X)

Dim y, L As Integer
Dim N As String

L = Len(X)
For y = 1 To L
If IsNumeric(Mid(X, y, 1)) Then
N = N & Mid(X, y, 1)
End If
Next y
getnumbersFromMemo = Val(N)
End Function

On the unbound text box (control source) I have put in =getnumbersFromMemo([X]). However this only shows #Name? What am I doing wrong. Note that I am a beginner and hence a clear explanation would be appreciated.
 
If you are sending the function X as a parameter, literally [X], then this is the problem

try =getnumbersFromMemo([X]) and replace X with the name of the field you wish to search with the function.
Usually #Name means access doesnt cannot find the field name entered as a control source.

The function receives the field name as a parameter and in example is called X, 'X' is OK here and you dont have to change it.,
but you could replace it with any unreserved word, but in that case you must also replace all the other 'X''s in the function to
same name.
 
Ron, it worked. Much appreciated.
 

Users who are viewing this thread

Back
Top Bottom