Code Proofreading Help (1 Viewer)

mbentley

Registered User.
Local time
Today, 08:00
Joined
Feb 1, 2002
Messages
138
When I run the following code I get an error (see attachment) at the last line. I've checked that all the table and field references are correct. Can anyone see a problem anywhere? (Note that GetBackendPath is a function that finds the path to the table, and it works fine. frmCurrent is a Form variable identifying the form that called the subroutine):

Dim cnnLayout As ADODB.Connection, rstLayout As ADODB.Recordset, strSQL As String

strSQL = "SELECT PatientID, DiagnosticType, ReportSection, Position, DefaultPosition " & _
"FROM tbl_Admin_AssessmentReportLayout " & _
"WHERE PatientID=" & frmCurrent.txtPatientID & _
" ORDER BY Position DESC"

Set cnnLayout = New ADODB.Connection
With cnnLayout
.Provider = CurrentProject.Connection.Provider
.ConnectionString = GetBackendPath("tbl_Admin_AssessmentReportLayout")
.Open
End With

Set rstLayout = New ADODB.Recordset
rstLayout.Open strSQL, cnnLayout, adOpenDynamic, adLockOptimistic
 

Attachments

  • error.jpg
    error.jpg
    9.6 KB · Views: 76
Last edited:

mbentley

Registered User.
Local time
Today, 08:00
Joined
Feb 1, 2002
Messages
138
Solution

Found the problem, so I thought I'd share. For some reason it didn't like the field name "Position". Changed that word and it worked OK. Must be a reserved word or something.
 

Users who are viewing this thread

Top Bottom