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