How to carry over to new line

solty89

Registered User.
Local time
Today, 03:41
Joined
May 20, 2013
Messages
32
Hey guys,
Im using "INSERT INTO tablename(a1,a2)" function but i have to many "a" objecjts. How to carry over to a new line without having error?
 
do you mean carrying over the code to a new line, use this
"INSERT INTO tablename(a1, a2, a3, a4, " _
& ",a5, a6)"
 
I've tryed this..still giving me syntax error :(
 
can you please post all of the offending line(s) of code and use code tags, I suspect it's nothing to do with carrying over, but data type syntax

David
 
Private Sub addrecord_Click()

'add data to table

CurrentDb.Execute "INSERT INTO FourniturenSample (Lila, Code, LilaP1, CodeP1, ColorP1, quantityP1, LilaP2, CodeP2, ColorP2, quantityP2, LilaP3, CodeP3, ColorP3, quantityP3, LilaP4, CodeP4, ColorP4, quantityP4, LilaP5, CodeP5, ColorP5, quantityP5, LilaP6, CodeP6, ColorP6, quantityP6, LilaP7, CodeP7, ColorP7, quantityP7, LilaP8, CodeP8, ColorP8, quantityP8, LilaP9, CodeP9, ColorP9, quantityP9, LilaP10, CodeP10, ColorP10, quantityP10, LilaP11, CodeP11, ColorP11, quantityP11, LilaP12, CodeP12, ColorP12, quantityP12, LilaP13, CodeP13, ColorP13, quantityP13, LilaP14, CodeP14, ColorP14, quantityP14, LilaP15, CodeP15, ColorP15, quantityP15, LilaP16, CodeP16, ColorP16, quantityP16, LilaP17, CodeP17, ColorP17, quantityP17, LilaP18, CodeP18, ColorP18, quantityP18, LilaP19, CodeP19, ColorP19, quantityP19, LilaP20, CodeP20, ColorP20, quantityP20) " & _
" VALUES('" & Me.txtlila & "','" & Me.txtlilacode & "','" & Me.txtlilapart1 & "','" & Me.txtlilacodepart1 & "','" & Me.txtcolorpart1 & "','" & Me.quantity1 & "','" & Me.txtlilapart2 & "','" & Me.txtlilacodepart2 & "','" & Me.txtcolorpart2 & "','" & Me.quantity2 & "','" & Me.txtlilapart3 & "','" & Me.txtlilacodepart3 & "','" & Me.txtcolorpart3 & "','" & Me.quantity3 & "','" & Me.txtlilapart4 & "','" & Me.txtlilacodepart4 & "','" & Me.txtcolorpart4 & "','" & Me.quantity4 & "','" & Me.txtlilapart5 & "','" & Me.txtlilacodepart5 & "','" & Me.txtcolorpart5 & "','" & Me.quantity5 & "','" & Me.txtlilapart6 & "','" & Me.txtlilacodepart6 & "','" & Me.txtcolorpart6 & "','" & Me.quantity6 & "','" & Me.txtlilapart7 & "','" & Me.txtlilacodepart7 & "','" & Me.txtcolorpart7 & "','" & Me.quantity7 & "','" & Me.txtlilapart8 & "','" & Me.txtlilacodepart8 & _
"','" & Me.txtcolorpart8 & "','" & Me.quantity8 & "','" & Me.txtlilapart9 & "','" & Me.txtlilacodepart9 & "','" & Me.txtcolorpart9 & "','" & Me.quantity9 & _
"','" & Me.txtlilapart10 & "','" & Me.txtlilacodepart10 & "','" & Me.txtcolorpart10 & "','" & Me.quantity10 & "','" & Me.txtlilapart11 & "','" & Me.txtlilacodepart11 & "','" & Me.txtcolorpart11 & "','" & Me.quantity11 & "','" & Me.txtlilapart12 & "','" & Me.txtlilacodepart12 & "','" & Me.txtcolorpart12 & "','" & Me.quantity12 & "','" & Me.txtlilapart13 & "','" & Me.txtlilacodepart13 & "','" & Me.txtcolorpart13 & "','" & Me.quantity13 & "','" & Me.txtlilapart14 & "','" & Me.txtlilacodepart14 & "','" & Me.txtcolorpart14 & "','" & Me.quantity14 & "','" & Me.txtlilapart15 & "','" & Me.txtlilacodepart15 & "','" & Me.txtcolorpart15 & "','" & Me.quantity15 & "','" & Me.txtlilapart16 & "','" & Me.txtlilacodepart16 & "','" & Me.txtcolorpart16 & "','" & Me.quantity16 & "','" & Me.txtlilapart17 & "','" & Me.txtlilacodepart17 & "','" & Me.txtcolorpart17 & _
"','" & Me.quantity17 & "','" & Me.txtlilapart18 & "','" & Me.txtlilacodepart18 & "','" & Me.txtcolorpart18 & "','" & Me.quantity18 & _
"','" & Me.txtlilapart19 & "','" & Me.txtlilacodepart19 & "','" & Me.txtcolorpart19 & "','" & Me.quantity19 & "','" & Me.txtlilapart20 & "','" & Me.txtlilacodepart20 & "','" & Me.txtcolorpart20 & "','" & Me.quantity20 & "')"

'refresh data in list on form
FourniturenSamplesub.Form.Requery

End Sub



now like this is working but Id like to add more objects but when the INSERt INTO line ends i dont know how to carry it over
 
your syntax currently is only suitable for string data types, if your quantity objects are numbers, this code will fail.
For numbers you need to use:

Code:
" & Me.quantity & " or   '" + str(Me.quantity) + "'    works as well
 
your syntax currently is only suitable for string data types, if your quantity objects are numbers, this code will fail.
For numbers you need to use:

Code:
" & Me.quantity & " or   '" + str(Me.quantity) + "'    works as well

the code like this is WORKING...i just wanna make it bigger but i dont know how to carry over the line with "INSERT INTO" code...there is the problem ive already test it
 
The code you have, suggests that your table is not normalized.. Look up on Normalization.. Follow the Document for starters..
 
If Paul's suggestion is not applicable and this all has to be in one table, I think there is a limit on the number of characters in this type of SQL string. What happens if you cut this in half (halve the number of fields), does it run then?

David
 
If Paul's suggestion is not applicable and this all has to be in one table, I think there is a limit on the number of characters in this type of SQL string. What happens if you cut this in half (halve the number of fields), does it run then? David

now its running, but i want to double them and then its not running, becouse
i cant have all the "insert into" fields in 1 line. But even now when its running ive tried many ways to carry over the "INSERT INTO" line to a 2nd line but i dont know how.Anyone who can do this?is it possible?
 
do you mean carrying over the code to a new line, use this
"INSERT INTO tablename(a1, a2, a3, a4, " _
& ",a5, a6)"

i've solve it.U were close.Its :
"INSERT INTO tablename(a1, a2, a3, a4, " & _
",a5, a6)"
 

Users who are viewing this thread

Back
Top Bottom