Microsoft Access Using Visual Basic Routines
Visual Basic Datatypes Boolean Byte Currency Date Double Integer Long Object Single String Variant Hyperlink
Variables and Arrays Use of “Dim” e.g. Dim count as Integer Use of “Dim” to create arrays e.g. Dim intArray(1 To 10) as Integer
Initializations intVariable = 10 stringVariable = “Hello, world.” dateVariable = #02/02/2001#
Variable Scope and Lifetime PUBLIC: seen by all the procedures in that module PRIVATE: can be referenced from within the module in which it is declared
Selection Structures If Then statement1 statement2 Else statement3 statement4 End If
Selection Structures Select Case Case statements… Case statements… Case Else statements... End Select
Loops For = To statement 1... statement2... Next
Loops (contd…) Do Until statement 1... statement 2... Loop
Procedures Sub ( ) … Code for the procedure … End Sub
Data Objects DAO = Data Access Object RDO = Remote Data Object RDS = Remote Data Services ADO = ActiveX Data Object
Useful DAOs DAO = Data Access Object Database RecordSet
Database DAO Refers to the database open in the current workspace. Only one database per workspace. E.g. –Dim db as Database –Set db = CurrentDb
Recordset DAO There exists one Recordset object for every recordset currently open. A Recordset is the result of the execution of a query. E.g. Dim rs as Recordset Set rs = db.OpenRecordSet(“Login”)