MELJUN CORTES Visual Basic 6 Data Control and Visual Data Manager
DATA CONTROL AND
Using Visual Data Manager
Launch Visual Data Manager from the VB Add-Ins menu.
Choose File/New..., choose Access 7.0, and give the new database a
Right-click in the Database Window. (There appears to be no other way to
do this, nor any instructions that would lead you to this. I accidentally found
it when I was about to give up!) Click New Table in the pop-up menu. In the
resulting dialog box, give the new table a name.
Click the Add Field button. Enter a field name and field type. Click the Okay
button to add the new field to the list. Keep repeating for a few more fields.
When done, click Close to stop adding fields and then close the table
In the Database Window, you'll see the name of your new table. Doubleclick to open the table so you can add records to the table. You can come
back and add more records any time.
In Visual Data Manager, choose File/Open
Database, and open a database file, such as
the one you created a few minutes ago.
In the Utility menu, choose DataForm
Fill in a name for your form at the top of the
Dataform Designer dialog, and set the
RecordSource to a (the) table in your
Click the >> button to add all fields to this
Click on Build the Form. When it is done,
Data Controls Event
The Error event handles any error that occurs with the
database. Use this event to code what you want to
happen when an error occurs.
The Reposition event occurs when the user moves to
another record in the RecordSet.
The Validate event occurs prior to updates, either
because of moving to another record or explicitly
asking for an update to occur. Use this event to do
any validation on any of your form fields prior to
writing to the database. If a field is invalid, you can
cancel the update and the action that caused it by
setting Action=0 and Save=False.
RecordSource and RecordSet
The RecordSource tells where the data will
come from. You can think of the Recordset
property as the actual data that you've
requested using the RecordSource.
Data1.RecordSet.EOF -True if MoveNext has moved us past the
Data1.RecordSet.BOF - True if MovePrevious has moved us in
front of the first record
Data1.RecordSet.RecordCount - The number of records in the
RecordSet. This is accurate with small RecordSets. For large
RecordSets you may have to perform a MoveLast to get this actual
Data1.RecordSet.AbsolutePosition - The number of the current
record in the RecordSet. Starts at zero. This property does not
appear to be reliable in VB6. I put code to display this in the Data
Control's Reposition event, and sometimes it worked, sometimes it
gave odd results.
Data1.RecordSet!fieldname - The contents of a specific field in the
current record of the RecordSet. Replace fieldname with the valid
name of a field.
Other Codes For Data Control
Syntax : Data1.DatabaseName = App.Path &
databaseName.mdb” – Using this code you
may be able to move your application to other
folders and it will not crash.
s = Data1.Recordset!ZipCode – where s is
declared as string. You can directly pass the
value of the Zipcode field to s.