hi everyone, I need help on an error message. I am working on an environment that Access2003 (adp) as a front end and links to SQL server as a back end.
I am creating a table, which requests users insert a value(varchar) into the table throuth an input box on a form.
Please see the code is below: - Public Sub cmdAdd_Click()
-
Dim cmd As ADODB.Command
-
Set cmd = New ADODB.Command
-
Dim getStrUR As String
-
cmd.ActiveConnection = CurrentProject.Connection
-
cmd.CommandText = "INSERT INTO dbo.NoteStatEditRecord" & _
-
"(InputURNo)" & _
-
"VALUES(getInputNumber())"
-
cmd.Execute
-
End Sub
the function getInputNumber() valides user input through input box and extract valide values(8 digits numeric values) from the input box. I have test the function in immediate windows. it works fine.
the code is below: - Public Function getInputNumber() As String
-
getInputNumber = InputBox("Enter an existing URNo to populate records.", "Please enter the URNo")
-
If getInputNumber <> "" Then
-
Do While Not IsNumeric(getInputNumber) Or Len(getInputNumber) <> 8
-
getInputNumber = InputBox("URNo is 8 digits numeric value, which contains" & _
-
"no Letters and space. Please re-enter the URNo.", "Caution: Invalid input found")
-
If getInputNumber = "" Then
-
Exit Function
-
End If
-
Loop
-
-
Do While IsNull(DLookup("PID", "dbo.URs", "URNo = '" & getInputNumber & "'"))
-
getInputNumber = InputBox("URNo is not exist!")
-
If getInputNumber = "" Then
-
Exit Function
-
End If
-
Loop
-
End If
-
-
End Function
however, I am keeping receiving error message for the function cmdAdd_Click() above said that getInputNumber is not a recognised function name. See below:
Run-time error'-2147217900 (80040e14)':
'getInputNumber' is not a recognized function name.
Had anyone came across this issue before? Is there a solution? Thanks in advance for any suggestions. meng
3 3683
hi everyone, I need help on an error message. I am working on an environment that Access2003 (adp) as a front end and links to SQL server as a back end.
I am creating a table, which requests users insert a value(varchar) into the table throuth an input box on a form.
Please see the code is below:
Public Sub cmdAdd_Click()
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Dim getStrUR As String
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "INSERT INTO dbo.NoteStatEditRecord" & _
"(InputURNo)" & _
"VALUES(getInputNumber())"
cmd.Execute
End Sub
the function getInputNumber() valides user input through input box and extract valide values(8 digits numeric values) from the input box. I have test the function in immediate windows. it works fine.
the code is below:
Public Function getInputNumber() As String
getInputNumber = InputBox("Enter an existing URNo to populate records.", "Please enter the URNo")
If getInputNumber <> "" Then
Do While Not IsNumeric(getInputNumber) Or Len(getInputNumber) <> 8
getInputNumber = InputBox("URNo is 8 digits numeric value, which contains" & _
"no Letters and space. Please re-enter the URNo.", "Caution: Invalid input found")
If getInputNumber = "" Then
Exit Function
End If
Loop
Do While IsNull(DLookup("PID", "dbo.URs", "URNo = '" & getInputNumber & "'"))
getInputNumber = InputBox("URNo is not exist!")
If getInputNumber = "" Then
Exit Function
End If
Loop
End If
End Function
however, I am keeping receiving error message for the function cmdAdd_Click() above said that getInputNumber is not a recognised function name. See below:
Run-time error'-2147217900 (80040e14)':
'getInputNumber' is not a recognized function name.
Had anyone came across this issue before? Is there a solution? Thanks in advance for any suggestions. meng
- The Error you are describing would probably be generated if getInputNumber() were declared Privately in a Standard Code Module or Publicly in a Form's Code Module. getInputNumber() must be declared as Public in a Standard Code Module in order to be recognized.
- There also seems to be a problem with syntax. Since the getInputNumber() Function returns a String, you must qualify it before it can be used in the SQL Statement:
-
Dim cmd As ADODB.Command
-
Set cmd = New ADODB.Command
-
-
Dim getStrUR As String
-
-
cmd.ActiveConnection = CurrentProject.Connection
-
cmd.CommandText = "INSERT INTO dbo.NoteStatEditRecord (InputURNo) VALUES('" & getInputNumber() & "')"
-
cmd.Execute
- Good luck and let me know how you make out.
Many thanks ADezii, It works out!!!
As your pointed out that my problem is I didn't qualify the String returned by the getInputNumber() Function. I have replaced the string getInputNumber() with '" & getInputNumber() & "'. it works now!
Thanks for the two tips, I will keep that in mind in future :o)
Cheers
meng
Many thanks ADezii, It works out!!!
As your pointed out that my problem is I didn't qualify the String returned by the getInputNumber() Function. I have replaced the string getInputNumber() with '" & getInputNumber() & "'. it works now!
Thanks for the two tips, I will keep that in mind in future :o)
Cheers
meng
You are quite welcome, meng.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: newbie_mw |
last post by:
Hi, I need urgent help with a novice problem. I would appreciate any
advice, suggestions... Thanks a lot in advance! Here it is:
I created a sign-up sheet (reg.html) where people fill in their...
|
by: iqbal |
last post by:
Hi all,
We have an application through which we are bulk inserting rows into a
view. The definition of the view is such that it selects columns from
a table on a remote server. I have added the...
|
by: Chad Richardson |
last post by:
Is there a way in SQL Server 2000 to extract data from a table, such that
the result is a text file in the format of "Insert Into..." statements, i.e.
if the table has 5 rows, the result would be 5...
|
by: Johannes A. Brunner |
last post by:
Got a simple problem.
I code some site and because Im a freak I made my own session-handling.
When a user open up my site it will check if there is a ssid in the url
if not generate one. this will...
|
by: jtocci |
last post by:
I'm having a big problem with CREATE RULE...ON INSERT...INSERT
INTO...SELECT...FROM...WHERE when I want to INSERT several (20~50)
records based on a single INSERT to a view. Either I get a 'too...
|
by: rn5a |
last post by:
During registration, users are supposed to enter the following
details: First Name, Last Name, EMail, UserName, Password, Confirm
Password, Address, City, State, Country, Zip & Phone Number. I am...
|
by: radiodes |
last post by:
I am very new to SQL/Access, and only use it very limitedly, so
apologies
ahead of time.
I have a website that inserts data into an access database, using the
code
below. Basically, I've got...
|
by: radiodes |
last post by:
I have a website that inserts data into a database, using the code
below. Basically, I've got one INSERT INTO statement that inserts one
line of data into one database, and and then a php for...
|
by: Mike1961 |
last post by:
Hi all.
I have problem with this asp code:
strSplitDati = Split(request.Form("dati"), ",")
for i = LBound(strSplitDati) to (INT(UBound(strSplitDati)/4)-1)*4 step 4
...
|
by: EJO |
last post by:
with sql 2000 enterprise
Trying to build a stored procedure that will take the rows of a parent
table, insert them into another table as well as the rows from a child
table to insert into...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |