Sorry. I'm fairly new to this and a bit confused. I've written to other
tables without the the & and additonal quotes. I've included that too for
your input. Additional information on this problem is as follows:
AnesthRecs is an array, so I'm basically trying to update my table with
information derrived from my array.
fldConcur = Boolean in table txt
fldConcurNum = Integer in table number
auto = Integer in table number
Here's the other Update that I wrote that works.....
Dim strSQL As String
strSQL = "UPDATE Anesth SET [ip_anesth1] = Trim$([anesth1]), " & _
"[ip_opdate] = [operation-start-date], " & _
"[ip_pttype] = [patient type], " & _
"[ip_svtype] = [service-types], " & _
"[ip_ptmrn] = [pat-mrn], " & _
"[ip_lastname] = [lastname], " & _
"[ip_firstname] = [firstname], " & _
"[ip_Age1] = [Age1], " & _
"[ip_Age] = [Age], " & _
"[ip_ansstart] = [ans-start], " & _
"[ip_ansstop] = [ans-stop], " & _
"[ip_AN1] = Forms!FrmS23.ANESTHESIOLOGIST![AN1], " & _
"[ip_anstype] = Forms!FrmS23.AnesType![ans_antnum], " & _
"[ip_SUR1] = Forms!FrmS23.SURGEON![SUR1], " & _
"[ip_surgeon1] = Forms!FrmS23.SURGEON![surgeon1], " & _
"[ip_rescrna] = Forms!FrmS23.RESCRNA![RESCRNA], " & _
"[ip_rescrnanum] = Forms!FrmS23.RESCRNA![emp_empnum], " & _
"[ip_ansasa] = Forms!FrmS23.AnesType![ans_attempts], " & _
"[ip_preop] = Forms!FrmS23.PROCEDURES![pimem_line], " & _
"[ip_surgdesc] = Forms!FrmS23.SURGDESC![pimem_line] " & _
"WHERE Anesth.[fldpatacct] = [pat-acct];"
DoCmd.RunSQL strSQL
Brendan Reynolds said:
I can't be sure that this is the only problem with that code, because you
haven't said what 'anesthRecs' is or where and how it is declared and
initialized, or what the data types of the fields are. With that caveat,
one
problem with the code is that you have the references to the properties
inside the quotes when they need to be outside the quotes. Something like
....
sSQL = "Update Anesth Set fldConcur = " & .fldConcur & ", " _
& "fldConcurNum = " & .fldConcurNum & " " _
& "WHERE auto = " & .auto
--
Brendan Reynolds
Access MVP
I have the following code and it's not working. Any suggestions?
Sub UpdateDB(numRecs As Integer)
Dim i As Integer
Dim sSQL As String
For i = 0 To numRecs - 1
With anesthRecs(i)
sSQL = "Update Anesth Set fldConcur = .fldConcur, " _
& "fldConcurNum = .fldConcurNum " _
& "WHERE .auto = auto"
DoCmd.RunSQL sSQL
End With
Next i
End Sub