Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 62,361 times

Contents

Related Categories

DAO 3.6 Library - RefreshSQL

LouisRose

RefreshSQL

Remember in the first Sub that we wrote we included a call to a sub called RefreshSQL. This is a very important procedure, it binds the database that you wish to you to variables that all of the procedures that we have written so far can use.

All of the code I have given you so far belongs in the module we created called modDatabase. You can add this to any project that you wish to add database capabilities to. To complete functionality though, this module relies on another sub, RefreshSQL. This is different depending on which data you wish to extract from the database and what your database contains. For this reason, RefreshSQL could be different in every project you write.

So by adding modDatabase to your project, you're only 80% of the way to adding database functionality. You should also include another module, which I usually call modDefaultDatabase, with unique code in dependant on the database you are manipulating.

This module should include:

  • Declarations of recordset variables.
  • A RefreshSQL procedure.

A sample modDefaultDatabase is below, showing you what I mean by the above:

Option Explicit

Global rstPeople As Recordset
Global rstAnimal As Recordset

Sub RefreshSQL()
   Dim strSQL As String

   strSQL = "SELECT * FROM [People]"
   Set rstPeople = db.OpenRecordset(strSQL)

   strSQL = "SELECT * FROM [Animals]"
   Set rstAnimals = db.OpenRecordset(strSQL)
End Sub


Make sure your RefreshSQL procedure binds ALL of your recordset variables to a recordset using SQL, as shown above. For a better understanding of SQL, see James Crowley's excellent article which can be found here.

Comments

  • Re: [2527] DAO 3.6 Library

    Posted by BarbStewart on 12 Jun 2008

    I am working in VB6 with an Access db and would like to delete records from a join table. Can you help me? I have a table of Products, and table of Materials and a table to join the...

  • Re: [2527] DAO 3.6 Library

    Posted by faisalwadood on 20 Feb 2007

    hi sir!


    i hav read your article fully,i also read many articles on vb databases i understand it well yet i hav have a problem if you kindly help me.


    i want to develop a vb applicati...

  • Re: [2527] DAO 3.6 Library

    Posted by Nishantha on 13 Jul 2006


    Dear Sir,


    <...

  • Bad Type

    Posted by StevoMc on 14 Jul 2004

    This tutorial has been really good for helping me understand how to use access databases, which is really cool, but unfortunately I'm having a problem.

    When writing the code for moddefaultdatabase...

  • Posted by bruwmac on 22 Jun 2004

    What? Where the heck did that come from?

    :eek: :confused: :D