473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Insert Into..Values(function())..

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:

Expand|Select|Wrap|Line Numbers
  1. Public Sub cmdAdd_Click()
  2.     Dim cmd As ADODB.Command
  3.     Set cmd = New ADODB.Command
  4.     Dim getStrUR As String
  5.         cmd.ActiveConnection = CurrentProject.Connection
  6.         cmd.CommandText = "INSERT INTO dbo.NoteStatEditRecord" & _
  7.             "(InputURNo)" & _
  8.             "VALUES(getInputNumber())"
  9.         cmd.Execute
  10. 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:

Expand|Select|Wrap|Line Numbers
  1. Public Function getInputNumber() As String
  2.     getInputNumber = InputBox("Enter an existing URNo to populate records.", "Please enter the URNo")
  3.     If getInputNumber <> "" Then
  4.         Do While Not IsNumeric(getInputNumber) Or Len(getInputNumber) <> 8
  5.         getInputNumber = InputBox("URNo is 8 digits numeric value, which contains" & _
  6.                         "no Letters and space. Please re-enter the URNo.", "Caution: Invalid input found")
  7.                         If getInputNumber = "" Then
  8.                             Exit Function
  9.                         End If
  10.         Loop
  11.  
  12.         Do While IsNull(DLookup("PID", "dbo.URs", "URNo = '" & getInputNumber & "'"))
  13.            getInputNumber = InputBox("URNo is not exist!")
  14.                If getInputNumber = "" Then
  15.                    Exit Function
  16.                End If
  17.         Loop
  18.     End If
  19.  
  20.  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
Feb 11 '08 #1
3 3683
ADezii
8,834 Expert 8TB
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
  1. 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.
  2. 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:
    Expand|Select|Wrap|Line Numbers
    1. Dim cmd As ADODB.Command
    2. Set cmd = New ADODB.Command
    3.  
    4. Dim getStrUR As String
    5.  
    6. cmd.ActiveConnection = CurrentProject.Connection
    7. cmd.CommandText = "INSERT INTO dbo.NoteStatEditRecord (InputURNo) VALUES('" & getInputNumber() & "')"
    8. cmd.Execute
  3. Good luck and let me know how you make out.
Feb 11 '08 #2
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
Feb 11 '08 #3
ADezii
8,834 Expert 8TB
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.
Feb 11 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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...
7
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...
5
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...
8
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...
0
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...
6
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...
0
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...
1
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...
1
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 ...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.