"Robert" <ro**************@boeing.com> wrote in
news:11*********************@j55g2000cwa.googlegro ups.com:
Lyle gets the prize and his 1/1000 chance was exactly correct. Seems I
have an 2002/2003 database and was using a DAO recordset with the % in
the query. Well that returned zero records that match. However, when I
set the form.recordsource to the sql query with the % in the like
clause, I get a valid SQL query and it returns records.
I changed the % to * in the set rst = and I get 16 records but I get
invalid property errors when trying to set the form.recordsource to
rst.
I know I have a problem between ADO and DAO objects. I am now trying to
determine which type I would like to use. It seems from the discussions
on this forum that DAO is on the way out but not dead. However most
examples I find on the web and in help are from DAO methods. This
database is currently static and in MS Access. I don't see it migrating
to SQL server anytime soon but change is always a constant so who
knows. How difficult is it to change from DAO to ADO or vice versa?
I would prefer to stay in the most current technology but it really
seems to be getting in the way.
Suggestions?
If you are going Access to Jet(Access) and binding your forms and reports
then TTBOMK you have to use DAO. (Well, there's another way but it's
arcane and I don't know of anyone else who does it, and the definition of
"binding" is stretched.)
Until we see ACE who can know for sure what will be appropriate? I know
we have predictions, statements of intention, etc. These are great but
can we be sure everything will be as it is planned?
You can set a form's recordset to an ADO recordset in Access ... hmmmmmmm
2002 at least ... not sure if it goes back to 2000, and a report's
recordset in an ADP in 2003, and there are some advantages to this,
including being able to edit the form within a transaction and
disconnecting the recordset.
But the recordset's properties must be set to specific values. This is an
example of the Transaction thing.
Dim c As ADODB.Connection
Private Sub Form_Close()
With c
If MsgBox("Save Changes?", vbYesNo Or vbQuestion) = vbYes Then
.CommitTrans
Else
.RollbackTrans
End If
End With
End Sub
Private Sub Form_Open(Cancel As Integer)
Dim r As ADODB.Recordset
Set c = CurrentProject.Connection
c.BeginTrans
Set r = New ADODB.Recordset
With r
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
.CursorType = adOpenStatic
.ActiveConnection = c
.Open "SELECT * FROM Table1"
End With
Set Me.Recordset = r
End Sub
'I'm undecided about the necessity of this
Private Sub Form_Error(DataErr As Integer, Response As Integer)
c.RollbackTrans
End Sub
Is this worthwhile? For me it's OK because I try to run ADO exclusively.
But I'm doing this mostly to see if it can be done, and how well. Even so
Access does DAO things behind the scenes. So for most, with Access FE,
JET BE I'd recommend DAO (which should not be construed that I recommend
manipulating DAO recordsets; I recommend executing SQL instead and this
will almost always be simpler, safer and quicker.)
--
Lyle Fairfield