Update a field in an MS SQL 2000 table from an Access Module

R

richardb

I am pretty familiar with SELECTING data from an MS SQL server database, but
have not mastered writing information back to an SQL table. It would be a
major breakthrough for me if someone would guide me to a simple code sample
or complete the attached sample. Thank you. My attempt so far:

Public Function UpdateTest(strEpisodeID As String, PreCert As String) As
Boolean
On Error GoTo ErrorHandler
Dim mydb As DAO.Database
Dim myq As DAO.QueryDef
Dim myrs As DAO.Recordset
Dim sqltext As String, strConnect As String
Set mydb = CurrentDb
Set myq = mydb.CreateQueryDef("")

sqltext = "UPDATE InsuranceA SET preauth_no = '" & PreCert & "' " & _
"WHERE EpisodeID = '" & strEpisodeID & "' ;"

strConnect = "ODBC;DSN=PPM_700;;Network=DBMSSOCN;Trusted_Connection=Yes"


With myq
.Connect = strConnect
.SQL = sqltext --- is this correct??
Set myrs = .OpenRecordset
End With

With myrs
------- 'What goes here??
End With

UpdateTest_Exit:
Set myrs = Nothing
myq.Close
Set myq = Nothing: Set mydb = Nothing
Exit Function

ErrorHandler:
MsgBox Err.Number & " - " & Err.Description, vbCritical, "Error in
IsEpisode"
Resume UpdateTest_Exit

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top