Re: Sql code in access form in adp

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks for that - you have giivejn me an essential piece of information
about where the query acvtually runs.

BUT IT STILL DOESNT RUN - not your fault.

Where should this click reside, currently on the on click function in a
command button (as cose)!

Would an "autonumber field in the table be interfering.

Is there ANYWHERE else should i be looking. No errors are thrown up or
anything indicating the problem.

I am the virge of giving up on this.

Thanks for all the help you have given me.
--
Learning is Never ending. So is certification.


"Sylvain Lafontaine" wrote:

Hi,

I'm not sure to which "last posting" you are making a reference. Is
this the one with the following piece of code:

SQL = "INSERT INTO log ([Admin],[Issue])" _
& " select '" & forms!frm_tick_entry![adm_name] & "', " _
& "'" & forms!frm_tick_entry![Problem] & "'"

or:

SQL = "INSERT INTO log ([Admin],[Issue])" _
& " Values ('" & forms!frm_tick_entry![adm_name] & "', " _
& "'" & forms!frm_tick_entry![Problem] & "')"

These two exemples have two fields, so there wouldn't be any real difference
if you want to have more.

And now about your last example:

SQL = "INSERT INTO log ([Admin],[Issue])" _
& " select [adm_name],[Problem]" _
& " from " & forms!frm_tick_entry"

This one cannot work because you cannot make a Select statement from a Form
because SQL-Server doesn't know anything about the forms on your local
machine. (Don't forget that all SQL code are running "remotely" on the
server, even when the server is on the same local machine.)

My two exemple above build the whole sql string using all required values
from the form. When this string has been built, it can be sent to the
server to be run there.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


"Roger" <Roger@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:47D8B795-7985-4F34-AC51-A846E903BE18@xxxxxxxxxxxxxxxx
Is this in conjunction with the last posting which includes the sql
coding.

If so then I cannot do what i want because I am referring to several text
boxes on one form and not just one. OR can i like it together and transfer
end box indiviually.

Would this work
Insert Into log
set admin = adm_name, issue=problem
from form!frm_tick_entry

Or is it the same problem.

Thankyou for your assistance - thiis is driving me mad.

I had tried the sql from the other posts - nothing happens at all - doesnt
even throw up an error.

--
Learning is Never ending. So is certification.


"Sylvain Lafontaine" wrote:

Also, you cannot use "from forms!frm_tick_entry" inside a T-SQL on the
SQL-Server. You must convert the value before calling DoCmd.RunSQL:

SQL = "INSERT INTO log ([Admin],[Issue])" _
& " select [adm_name],[Problem]" _
& " from " & forms!frm_tick_entry"

If this value is a string, then you must not forget to enclose it between
single quotes.

The name of the forms is also missing, should be:

... & forms!Name_of_the_Form!frm_tick_entry

--
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.






.


Quantcast