Accessing DAO as the Data Control Does

Accessing DAO as the Data Control Does

Post by Sandy Atkinso » Wed, 13 May 1998 04:00:00



When I use the Data Control attached to a DAO Recordset it is able to figure
out when a move/find/update occurs on the recordset and creates the validate
and reposition events.

I need to create an object like the data control that can generate these
events, but there does not seem to be an api for the DAO that generates
these events.

Does anybody know how to do this

Thanks

Sandy Atkinson

 
 
 

Accessing DAO as the Data Control Does

Post by Michael Conra » Thu, 14 May 1998 04:00:00


You have to use the DAO manual:

Dim ws as Workspace
Dim db as Database
Dim rd as Recordset
Dim qd as QueryDef
Dim fi as Field

    set ws = DbEngine.Workspace(0)
    set db = ws.OpenDatabase("Test1.mdb")

For more Infos the VB Help would be helpfull

    The "db" has the same Events and Properties like a DataControll
    You can Create a Database, Tabeldef, Querydef etc.

Sandy Atkinson schrieb in Nachricht ...

Quote:>When I use the Data Control attached to a DAO Recordset it is able to
figure
>out when a move/find/update occurs on the recordset and creates the
validate
>and reposition events.

>I need to create an object like the data control that can generate these
>events, but there does not seem to be an api for the DAO that generates
>these events.

>Does anybody know how to do this

>Thanks

>Sandy Atkinson


 
 
 

Accessing DAO as the Data Control Does

Post by Johan Savel » Thu, 14 May 1998 04:00:00


Hi Sandy,

You will have to code it yourself, like for the click event of a next record
button:

Private Sub cmdNext_click()
    recordsetname.MoveNext
    If recordsetname.EOF Then
        recordsetname.MoveLast
    End If
End Sub

For each event that can cause trouble you have to add code to check if an
error might occur and react on it.

--
Johan Savels
Trainer Data Bases & Visual Basic
Royal Technical School of the Belgian Air Force
----------------------------------------------------------------------------
-


>When I use the Data Control attached to a DAO Recordset it is able to
figure
>out when a move/find/update occurs on the recordset and creates the
validate
>and reposition events.

>I need to create an object like the data control that can generate these
>events, but there does not seem to be an api for the DAO that generates
>these events.

>Does anybody know how to do this

>Thanks

>Sandy Atkinson

 
 
 

Accessing DAO as the Data Control Does

Post by Sandy Atkinso » Thu, 14 May 1998 04:00:00


This isn't quite what my problem is.  I am writing a non-visual activex dll
that works somewhat like a VB Data Control.  It needs to fire the equivalent
of the VB Data Control's "REPOSITION" and "VALIDATE" events.  However, I
can't see a way for it to detect when the VB Recordset is changing the
record position ( for example when a user executes the following code )

NonVisualDataControl.Recordset.MoveFirst.

If you do this with a "real" data control you get the Validate and
Reposition events fired by the Data Control.

There must be some way of doing this because the VB Data Control does it -
unless the VB environment has some special code in the Recordset object
which is not accessible to any control other than the VB Data Control.

Thanks again

...Sandy


>Hi Sandy,

>You will have to code it yourself, like for the click event of a next
record
>button:

>Private Sub cmdNext_click()
>    recordsetname.MoveNext
>    If recordsetname.EOF Then
>        recordsetname.MoveLast
>    End If
>End Sub

>For each event that can cause trouble you have to add code to check if an
>error might occur and react on it.

>--
>Johan Savels
>Trainer Data Bases & Visual Basic
>Royal Technical School of the Belgian Air Force
>---------------------------------------------------------------------------
-
>-

 
 
 

Accessing DAO as the Data Control Does

Post by Stuart Greenbe » Mon, 25 May 1998 04:00:00




> This isn't quite what my problem is.  I am writing a non-visual activex dll
> that works somewhat like a VB Data Control.  It needs to fire the equivalent
> of the VB Data Control's "REPOSITION" and "VALIDATE" events.  However, I
> can't see a way for it to detect when the VB Recordset is changing the
> record position ( for example when a user executes the following code )

> NonVisualDataControl.Recordset.MoveFirst.

> If you do this with a "real" data control you get the Validate and
> Reposition events fired by the Data Control.

> There must be some way of doing this because the VB Data Control does it -
> unless the VB environment has some special code in the Recordset object
> which is not accessible to any control other than the VB Data Control.

> Thanks again

> ...Sandy


> >Hi Sandy,

> >You will have to code it yourself, like for the click event of a next
> record
> >button:

> >Private Sub cmdNext_click()
> >    recordsetname.MoveNext
> >    If recordsetname.EOF Then
> >        recordsetname.MoveLast
> >    End If
> >End Sub

> >For each event that can cause trouble you have to add code to check if an
> >error might occur and react on it.

> >--
> >Johan Savels
> >Trainer Data Bases & Visual Basic
> >Royal Technical School of the Belgian Air Force
> >---------------------------------------------------------------------------
> -
> >-

You sure know how to hurt a guy! :)

I'm doing the same thing. I have a class that replaces the data control.
Everything works fine except the case you mention. The only way I know to
do this (at the moment) is to add a timer to your class that continually
checks the bookmark of the current record to that of the last move your
class processed directly. There will be a slight delay but if the
interval of the timer is short enough the user won't notice it.

My only concern with this methodology is that it adds unnecessary
overhead to the app. If VB supported true OOP I would derive a new
recordset class from the existing recordset class and add the
notification capability. To do this in VB you have to create a class that
contained a recordset and duplicate the recordset's interface. All
defined properties and methods would be passed directly to the underlying
recordset except the movement methods. These would be passed to the
underlying recordset and also raise an event. A developer would access
this pseudo-recordset through the Recordset property of your data control
class.

The drawback? Whenever the recordset object is refined in a new release
of DAO you would have to immediately release an update of your data
control class to support it.

The alternative is to disallow direct changes to the underlying
recordset. I'll have to give this a lot of thought before making a final
decision.

If you want to discuss it further contact me via email.

-Stu
--
The first Gumdrop has been posted. More on the way...
GUI Gumdrops - Tasty Morsels for Windows Developers
http://www.guigumdrops.com

For information about the VB SIG of the Long Island PC Users'Group
visit the LIPCUG web site at:
http://www.li.net/~lipcug
To be placed on the mailing list, send an email with the subject
"VB SIG Mailing List" to:


See web site for directions.

 
 
 

1. Using MS Data Control DAO to access a password protected database

Can anybody help?

I am trying to secure an mdb file so that the user has no access through MS
Access. My project uses ms data controls. I can connect using opendatabase
but cannot get the data controls to log on as they require a password.

ie. data1.databasename=

Is there any way to get it to see a password, or do I just have write the
data directly to the controls with my own recordset?

2. Which Svc Pack installed??

3. dao data control & access 2000

4. Undocumented INIT parameters

5. Creating Function-Based Indexes

6. Problem: VB5, Access, DAO and Data Controls

7. How to run multiple versions of ORACLE on the save NT box ?

8. Access Path Error on Installation using DAO data control

9. old DAO data control / Access 2000 / Object Library?

10. Accessing DAO Like the Data Control Does

11. (Urgent) Use Data Control (DAO) to open a password protected Access Database

12. DAO VB4, SSTab Control, Data Control FREEZE UP