R
ryguy7272
I am working with the following code:
Private Sub Command1_Click()
Dim err As Integer
Dim cnn1 As ADODB.Connection
Dim rstPatientTable As ADODB.Recordset
Dim strCnn As String
'if no errors insert data
If err < 1 Then
' Open a connection.
Set cnn1 = New ADODB.Connection
mydb = "C:\Documents and Settings\rms\Desktop\Contacts.mdb"
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mydb
cnn1.Open strCnn
' Open contact table.
Set rstPatientTable = New ADODB.Recordset
rstPatientTable.CursorType = adOpenKeyset
rstPatientTable.LockType = adLockOptimistic
rstPatientTable.Open "PatientTable", cnn1, , , adCmdTable
'get the new record data
rstPatientTable.AddNew
rstPatientTable!FirstName = txtFirstName
rstPatientTable!LastName = txtLastName
rstPatientTable!ConsultDate = txtConsultDate
rstPatientTable!SIM_Date = txtSIM_Date
rstPatientTable!RT_STart = txtRT_Start
rstPatientTable!RT_End = txtRT_End
rstPatientTable.Update
' Show the newly added data.
MsgBox "New patient: " & rstPatientTable!FirstName & " " &
rstPatientTable!FirstName & " has been successfully added!!"
'close connections
rstPatientTable.Close
cnn1.Close
Else
MsgBox "An Error has occurred, please check and try again"
End If
End Sub
I get a message that reads 'Compile Error: User-defined type not defined'.
I have a reference set to Microsoft ADO Ext. 2.8 for DDL and Security
I can't seem to update my 'PatientTable'. What am I doing wrong?
Also, is there a way to set the DB to anyone's desktop, using a relative
reference, instead of this hard-coded reference:
mydb = "C:\Documents and Settings\rms\Desktop\Contacts.mdb"
I am planning to email this DB to a few people, once it is operational, and
the people who will receive this don't know any VBA at all.
I'd sincerely appreciate any help with this!
Thanks,
Ryan---
Private Sub Command1_Click()
Dim err As Integer
Dim cnn1 As ADODB.Connection
Dim rstPatientTable As ADODB.Recordset
Dim strCnn As String
'if no errors insert data
If err < 1 Then
' Open a connection.
Set cnn1 = New ADODB.Connection
mydb = "C:\Documents and Settings\rms\Desktop\Contacts.mdb"
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mydb
cnn1.Open strCnn
' Open contact table.
Set rstPatientTable = New ADODB.Recordset
rstPatientTable.CursorType = adOpenKeyset
rstPatientTable.LockType = adLockOptimistic
rstPatientTable.Open "PatientTable", cnn1, , , adCmdTable
'get the new record data
rstPatientTable.AddNew
rstPatientTable!FirstName = txtFirstName
rstPatientTable!LastName = txtLastName
rstPatientTable!ConsultDate = txtConsultDate
rstPatientTable!SIM_Date = txtSIM_Date
rstPatientTable!RT_STart = txtRT_Start
rstPatientTable!RT_End = txtRT_End
rstPatientTable.Update
' Show the newly added data.
MsgBox "New patient: " & rstPatientTable!FirstName & " " &
rstPatientTable!FirstName & " has been successfully added!!"
'close connections
rstPatientTable.Close
cnn1.Close
Else
MsgBox "An Error has occurred, please check and try again"
End If
End Sub
I get a message that reads 'Compile Error: User-defined type not defined'.
I have a reference set to Microsoft ADO Ext. 2.8 for DDL and Security
I can't seem to update my 'PatientTable'. What am I doing wrong?
Also, is there a way to set the DB to anyone's desktop, using a relative
reference, instead of this hard-coded reference:
mydb = "C:\Documents and Settings\rms\Desktop\Contacts.mdb"
I am planning to email this DB to a few people, once it is operational, and
the people who will receive this don't know any VBA at all.
I'd sincerely appreciate any help with this!
Thanks,
Ryan---