Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Inserting Into SQL Server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sash - 06 Nov 2006 21:04 GMT
I have ODBC Connection to db and I'm trying to insert fldpatacct into a table
dbo_Anesth where the value is equal to the value on a form.  The reason I do
it this way is that I look at several other fields before deciding to actuall
insert the record.    

Dim mepatacct As String
Dim strSQLpat As String
   
   mepatacct = Me.Text1.Value
   
   strSQLpat = "INSERT INTO dbo_Anesth(fldpatacct)VALUES('" & mepatacct &
"')"
   DoCmd.RunSQL , strSQLpat

   
   DoCmd.OpenForm StDocName, , , stLinkCriteria
   DoCmd.Close acForm, stDocName2
Brendan Reynolds - 07 Nov 2006 14:54 GMT
The SQL statement is the *first* argument to the RunSQL method, not the
second argument. In other words, this ...

DoCmd.RunSQL , strSQLpat

... needs to change to ...

DoCmd.RunSQL strSQLpat

Signature

Brendan Reynolds
Access MVP

>I have ODBC Connection to db and I'm trying to insert fldpatacct into a
>table
[quoted text clipped - 15 lines]
>    DoCmd.OpenForm StDocName, , , stLinkCriteria
>    DoCmd.Close acForm, stDocName2
Sash - 07 Nov 2006 15:01 GMT
Thank you.  It now looks like it's running, but it doesn't insert the record.
Could it be that something on the SQL Server side is not allowing updates.  

> The SQL statement is the *first* argument to the RunSQL method, not the
> second argument. In other words, this ...
[quoted text clipped - 24 lines]
> >    DoCmd.OpenForm StDocName, , , stLinkCriteria
> >    DoCmd.Close acForm, stDocName2
Brendan Reynolds - 07 Nov 2006 15:23 GMT
Could be, but I'd expect an error message if that were the case. If you're
using 'On Error Resume Next' try commenting it out and see if you get an
error message. Otherwise, in the absence of any further information, I'm not
sure what to suggest.

Signature

Brendan Reynolds
Access MVP

> Thank you.  It now looks like it's running, but it doesn't insert the
> record.
[quoted text clipped - 30 lines]
>> >    DoCmd.OpenForm StDocName, , , stLinkCriteria
>> >    DoCmd.Close acForm, stDocName2
Stefan Hoffmann - 07 Nov 2006 15:36 GMT
hi Sash,

> Thank you.  It now looks like it's running, but it doesn't insert the record.
>  Could it be that something on the SQL Server side is not allowing updates.  
Use instead of DoCmd.RunSQL the following:

  Dim db As DAO.Database

  Set db = CurrentDb

  db.Execute strSQLpat, dbFailOnError
  MsgBox db.RecordsAffected

mfG
--> stefan <--
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.