Re: Sql code in access form in adp
- From: "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
- Date: Fri, 17 Feb 2006 01:46:23 -0500
Forget about my last answer, the missing blank spaces and name of the
control after the name of the form got me distracted. Here is your correct
solution for two fields:
SQL = "INSERT INTO log ([Admin],[Issue])" _
& " select '" & forms!frm_tick_entry![adm_name] & "', " _
& "'" & forms!frm_tick_entry![Problem] & "'"
Notice that the values of adm_name and Problem have been delimited by single
quote ' because they are probably string characters from their name. If
they are integer values, then drop these single quotes. Another solution
would be to use the keyword Values instead of a Select statement:
SQL = "INSERT INTO log ([Admin],[Issue])" _
& " Values ('" & forms!frm_tick_entry![adm_name] & "', " _
& "'" & forms!frm_tick_entry![Problem] & "')"
The Select statement can be used to insert multiple records in a single
statement, however you cannot use this feature here because it requires that
the source is a table; not a form or a list of values.
Finally, make sure that the SQL string is correct by displaying it in a
message box.
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"Roger" <Roger@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7AF95CF8-A26B-4681-A42A-3A2ADF30AC60@xxxxxxxxxxxxxxxx
--
Learning is Never ending. So is certification.
"Sylvain Lafontaine" wrote:
Probably missing blank spaces.Heres one a little more challengingI assume that the from line is wrong as
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"Roger" <Roger@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4C14FC0C-A863-4F2C-A275-8B1AB3A7FA4F@xxxxxxxxxxxxxxxx
Whats wrong with this Private Sub Save_Record_Click()
Dim SQL As String
SQL = "INSERT INTO log ([Admin],[Issue])" _
& "select [adm_name],[Problem]" _
& "from forms!frm_tick_entry"
DoCmd.RunSQL SQL
End Sub
Access2003 - sql200 back end
I am trying to create a code which will copy information from a form to
a
table.
table = log
Form = frm_tick_entry
I keep getting invalid syntax near !.
Help!!!!!!!
--
Learning is Never ending. So is certification.
Thanks for that
well. I need to tansfer all data from this form to a table - about 7
controls. What do i need to change for this to work.
I only put 2 here for brevity.
Much appreciated
.
- References:
- Re: Sql code in access form in adp
- From: Sylvain Lafontaine
- Re: Sql code in access form in adp
- Prev by Date: Re: Sql code in access form in adp
- Next by Date: Re: Parameterized queries
- Previous by thread: Re: Sql code in access form in adp
- Next by thread: Re: Sql code in access form in adp
- Index(es):
Relevant Pages
|