By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,780 Members | 1,126 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,780 IT Pros & Developers. It's quick & easy.

please correct me

100+
P: 274
hi every one I was using a query to insert some data and it worked fine. I had to add a new fields (Extension stored in...... txtvendor(0).text, its a numeric value) on form.It work fine if remove extension and it relavant field form thr query. I am getting error message Syntax error I can't pick why
here is my query

Expand|Select|Wrap|Line Numbers
  1. RS.Open "Insert into Vendor(account_no,customer,contact_person,address,city,postal_code,province,phone_number,Extension,licence_no,gst_no,pst_no,terms,description,status) values (" & Trim$(txtVendor(1).Text) & ",'" & Trim$(txtVendor(2).Text) & "','" & Trim$(txtVendor(3).Text) & "','" & Trim$(txtVendor(4).Text) & "','" & Trim$(txtVendor(5).Text) & "','" & Trim$(txtVendor(6).Text) & "','" & Trim$(txtVendor(7).Text) & "','" & Trim$(txtVendor(8).Text) & "'," & Trim$(txtVendor(0).Text) & ",'" & Trim$(txtVendor(9).Text) & "','" & Trim$(txtVendor(10).Text) & "','" & Trim$(txtVendor(11).Text) & "'," & Trim$(txtVendor(12).Text) & ",'" & Trim$(txtVendor(13).Text) & "','" & Trim$(txtVendor(14).Text) & "')", Conn, adOpenStatic, adLockOptimistic
thanks in advance
Nov 23 '07 #1
Share this Question
Share on Google+
7 Replies


debasisdas
Expert 5K+
P: 8,127
can you post what exactly is the error message.
Nov 23 '07 #2

QVeen72
Expert 100+
P: 1,445
Hi,

You dont need to open a Recordset for "Insert" Statements,
You Have to Execute Them on Connection or Command Object.
Say:

Conn.Execute "Insert Into ....."

Regards
Veena
Nov 23 '07 #3

lotus18
100+
P: 866
Hi,

You dont need to open a Recordset for "Insert" Statements,
You Have to Execute Them on Connection or Command Object.
Say:

Conn.Execute "Insert Into ....."

Regards
Veena
Hi Veena

I would like to respond with your post. I think you can still use the Recordset.Open for inserting or updating sql statements.

For creative1

Try this:

Expand|Select|Wrap|Line Numbers
  1. RS.Open "Insert into Vendor([account_no],[customer],[contact_person],[address],  [city],[postal_code],[province],[phone_number],[Extension],[licence_no],[gst_no],[pst_no],[terms],[description],[status]) values ('" & Trim$(txtVendor(1).Text) & "','" & Trim$(txtVendor(2).Text) & "','" & Trim$(txtVendor(3).Text) & "','" & Trim$(txtVendor(4).Text) & "','" & Trim$(txtVendor(5).Text) & "','" & Trim$(txtVendor(6).Text) & "','" & Trim$(txtVendor(7).Text) & "','" & Trim$(txtVendor(8).Text) & "','" & Trim$(txtVendor(0).Text) & "','" & Trim$(txtVendor(9).Text) & "','" & Trim$(txtVendor(10).Text) & "','" & Trim$(txtVendor(11).Text) & "','" & Trim$(txtVendor(12).Text) & "','" & Trim$(txtVendor(13).Text) & "','" & Trim$(txtVendor(14).Text) & "')", Conn, 3, 3
  2.  
I think you've forgot to insert '.

Good Luck : )
Nov 23 '07 #4

100+
P: 274
Hi Guys
Lotus18 is right Recordset.Open works for insert statement too.
I used the query that Lotus18 wrote in his post but noluck same error message.

P.S Extension is a numeric field sstored in txtVendot(0).text

If I don't use it with no error and complete transection, If I add this field I get following error when it reach the query:
Run time error SYNYAX ERROR in InsertInto statement. I realy don't whats wrong with this statement.


regards
Nov 24 '07 #5

Mohan Krishna
100+
P: 115
Hi Guys
:
:
P.S Extension is a numeric field sstored in txtVendot(0).text
:
Run time error SYNYAX ERROR in InsertInto statement. I realy don't whats wrong with this statement.
Hi Creative1 !
May I give a suggestion to my knowledge...
Can't we use VAL ( TRIM ( ... ) ) or INT ( TRIM (...) ) for that numeric field and instead of TRIM$ ?
Don't think otherwise if there is mistake in my suggestion!
ThanQ! ALL THE BEST!
Nov 24 '07 #6

100+
P: 274
Waooo! your tip worked I used
" & Val(Trim$(txtVendor(0).Text)) & "
and it worked .
thanks alot
Nov 24 '07 #7

lotus18
100+
P: 866
Waooo! your tip worked I used
" & Val(Trim$(txtVendor(0).Text)) & "
and it worked .
thanks alot
So for the next time you need to show us much more details. : )

ALL THE BEST MOHAN!!!
Nov 24 '07 #8

Post your reply

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