R
ryguy7272
I am using the following code to make updates to my Table named ‘PatientTable’:
Option Compare Database
Option Explicit
Dim cboOriginator As TextBox
Private Sub Command19_Click()
Dim err As Integer
Dim cnn1 As ADODB.Connection
Dim rstPatientTable As ADODB.Recordset
Dim strCnn As String
Dim mydb As String
If err < 1 Then
Set cnn1 = New ADODB.Connection
mydb = "C:\RTDA Tool.mdb"
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mydb
cnn1.Open strCnn
Set rstPatientTable = New ADODB.Recordset
rstPatientTable.CursorType = adOpenKeyset
rstPatientTable.LockType = adLockOptimistic
rstPatientTable.Open "PatientTable", cnn1, , , adCmdTable
rstPatientTable.Update
rstPatientTable!RT_Start_Date = RT_Start_Date
rstPatientTable!SIM_Comments = SIM_Comments
rstPatientTable.Update
MsgBox "Patient: " & Me![FirstName] & " " & Me![LastName] & " has
been successfully updated!!"
rstPatientTable.Close
cnn1.Close
Else
MsgBox "An Error has occurred, please check and try again"
End If
End Sub
When the macro fires, the code runs and it DOES update the Table, but the
updates always occur on the first record of the Table, it doesn’t update the
correct record. There must be a simple solution for this, but I don’t know
where to begin. On my Form I have a TextBox named ‘MR’; it is an ID. When I
type in an MR number, several TextBoxes on my Form update automatically.
This is fine! I can see a patient’s status, and add some new information via
several TextBoxes, the problem is that when the code fires, the updates
aren’t made to the correct records. How can I ensure that updates are made
to the appropriate record? The appropriate record is the number in the MR
TetxBox?
I’ve been working on this project most of the day; this is the last piece of
the puzzle. I would really appreciate it if someone could help me finish
this off!!
Thanks so much!!
Ryan---
Option Compare Database
Option Explicit
Dim cboOriginator As TextBox
Private Sub Command19_Click()
Dim err As Integer
Dim cnn1 As ADODB.Connection
Dim rstPatientTable As ADODB.Recordset
Dim strCnn As String
Dim mydb As String
If err < 1 Then
Set cnn1 = New ADODB.Connection
mydb = "C:\RTDA Tool.mdb"
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mydb
cnn1.Open strCnn
Set rstPatientTable = New ADODB.Recordset
rstPatientTable.CursorType = adOpenKeyset
rstPatientTable.LockType = adLockOptimistic
rstPatientTable.Open "PatientTable", cnn1, , , adCmdTable
rstPatientTable.Update
rstPatientTable!RT_Start_Date = RT_Start_Date
rstPatientTable!SIM_Comments = SIM_Comments
rstPatientTable.Update
MsgBox "Patient: " & Me![FirstName] & " " & Me![LastName] & " has
been successfully updated!!"
rstPatientTable.Close
cnn1.Close
Else
MsgBox "An Error has occurred, please check and try again"
End If
End Sub
When the macro fires, the code runs and it DOES update the Table, but the
updates always occur on the first record of the Table, it doesn’t update the
correct record. There must be a simple solution for this, but I don’t know
where to begin. On my Form I have a TextBox named ‘MR’; it is an ID. When I
type in an MR number, several TextBoxes on my Form update automatically.
This is fine! I can see a patient’s status, and add some new information via
several TextBoxes, the problem is that when the code fires, the updates
aren’t made to the correct records. How can I ensure that updates are made
to the appropriate record? The appropriate record is the number in the MR
TetxBox?
I’ve been working on this project most of the day; this is the last piece of
the puzzle. I would really appreciate it if someone could help me finish
this off!!
Thanks so much!!
Ryan---