I am familiar with recordsets in DAO, but I would like to start using ADO. My first attempt is not good. Here is my code, which is coming straight out of an Access 2002 book with my questions.
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Set rst.ActiveConnection = CurrentProject.AccessConnection
The book says it should be "CurrentProject.ActiveConnection", but when I type in CurrentProject ActiveConnection does not come up as a choice. So I am not sure if my choice is causing the problems.
rst.CursorType = adOpenStatic
rst.LockType = adLockOptimistic
rst.Open "Main Table"
When I try and run this I get a runtime error with the above line highlighted.
Invalid SQL statement; Expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT' or 'UPDATE'.
If Not rst.BOF And Not rst.EOF Then
Response = MsgBox("Not in there", vbDefaultButton1, "yes")
Do While rst.EOF <> True 'Continue if last find succeeded.
If IsNull(CCNnum) = False Then
Response = MsgBox("There is already a record with this CCN number", vbInformation, "CCN Found")
Any help would be very much appreciated.