n my attempt to organize the code in a more moduler state I
Created a module called ConnectCloseDB that contains two funtions
OpenDB() and Close DB
And in the main form I left
I get the following error “ Complile Error: Invalid or unqualfied reference”
The debug leads me to .EOF
I thought by opening the database and accomplishing the recordset with OpenDB function that I would be able to run task to be able to add, edit and use msgbox.
What am I missing???
Created a module called ConnectCloseDB that contains two funtions
OpenDB() and Close DB
Code:
Function OpenDB()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source") = "c:\Documents and Settings\cspence\Desktop\CHCB_Projects\NewAmericans.mdb"
' .Properties("Jet OLEDB:System database") = "\\serv1\db\NCAA.mdw"
' .Properties("User ID") = TheUserID
' .Properties("Password") = ThePassword
' .Properties("Persist Security Info") = False
.Properties("Mode") = adModeShareDenyNone
.Open
End With
With rs
.ActiveConnection = cn
.CursorLocation = adUseServer
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Source = "SELECT * FROM tblPatientLanguage"
.Open
End With
End Function
Function CloseDB()
rs.Close
End Function
And in the main form I left
Code:
Private Sub cmdSumbit_Click()
OpenDB
While Not .EOF
MsgBox "PatientID :" & .Fields("PatientID") & " and Language :" & .Fields("LanguageID")
.MoveNext
Wend
CloseDB
End Sub
I get the following error “ Complile Error: Invalid or unqualfied reference”
The debug leads me to .EOF
I thought by opening the database and accomplishing the recordset with OpenDB function that I would be able to run task to be able to add, edit and use msgbox.
What am I missing???