ADO/DAO Form.Recordset

  • Thread starter Michael G. Schneider
  • Start date
M

Michael G. Schneider

Suppose you have two MDBs, one for the GUI, the other for the data. I do not
want to use DAO, I want to use ADO.

Probably simple question, but what do I have to do for using ADO inspite of
DAO? I removed the reference to DAO, and inserted the reference to ADO. What
more has to be done?

For example, what about the Form.Recordset object? It is a DAO.Recordset
object. How can this be changed?
 
D

Douglas J. Steele

I don't believe you can change it.

Why do you want to? Given you're strictly using Jet (i.e. MDB files), DAO is
the preferred approach.
 
M

Michael G. Schneider

I don't believe you can change it.

Why do you want to? Given you're strictly using Jet (i.e. MDB files), DAO
is the preferred approach.

I haven't used DAO for years. I got used to using ADO.

My question in this forum was initiated by a problem, which I could not
solve with DAO but have a solution with ADO. So maybe you or somebody else
can help me with the basic question...

Suppose there is a bound form, its fields are directly connected to some
columns in a table. Now, if there is an error (such as 'column may not be
empty'), Access shows a message box giving that error. I would like to avoid
the message box and show the error (in an enhanced way) in my form. I tried
to use "Form_Error", but I could not make it work.

With ADO there is an event belonging to the recordset object, which can be
used for finding out about these errors. The ADO recordset object doesn't
seem to have any events at all.
 
M

Michael G. Schneider

Douglas J. Steele said:
What did you try in Form_Error?

Thank's a alot for your help.

There is a Form_Error event handler. For example, if a mandatory field is
not entered, it is fired with DataErr=3314. At the end of the procedure, I
set the response to 0 for telling Access "I took care of the error
handling".

However, at the start of the procedure I did not succeed in finding the
underlying error message - such as "field ZipCode may not be left empty".

- The Err object does not hold any error.

- The DBEngine.Errors collection is empty.

- The 3314 only tells me the general error message, not naming a specific
field.
 
D

david epsom dot com dot au

The forms recordset may be either ADO or DAO. It defaults
to DAO, but you can assign it to an ADO object, or assign
an ADO object to it.

(david)
 
D

david epsom dot com dot au

Each control has a validation text property. It is as good a place
as any to put validation text, which you can use like this example:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
'2006/03/06 dlg
Const INPUTMASK_VIOLATION = 2279
Dim Msg As String
If DataErr = INPUTMASK_VIOLATION Then
r_msgbox Application.Screen.ActiveControl.ValidationText
Beep
Response = acDataErrContinue
End If
End Sub


(david)
 
B

Brendan Reynolds

In an MDB, the Form.Recordset property returns a DAO recordset *unless* you
have previously assigned an ADO recordset to the property.

Michael Kaplan has an article on this at the following URL ...

http://www.trigeminal.com/usenet/usenet022.asp?1033

One thing that has changed since that article was written is that in Access
2003 assigning an ADO recordset to the Form.Recordset property no longer
makes the form read-only.

(This *may* also be true of Access 2002, I'm not sure about that.)

That said, I agree with Doug that DAO is generally the better choice when
using an Access app and a JET database.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top