access-vba

Topics related to access-vba:

Getting started with access-vba

This section provides an overview of what access-vba is, and why a developer might want to use it.

It should also mention any large subjects within access-vba, and link out to the related topics. Since the Documentation for access-vba is new, you may need to create initial versions of those related topics.

Enable/Disable Shift Key on DB Open

This code will turn off the capability for a user to hold down the Shift key when opening a database to skip the default form opening and allow the user access to the Navigation Pane and VB Editor. In DB’s that you do not want users to have access to either of these (along with disabling the use of Special Keys in the Current Database Options), this code will help to keep the database locked down.

Generally, the below code is placed in it's own Module that can be named basEnableDisableShift module, but this is just a suggestion and you can place it in any module that you may already have.

In order to disable the Shift key, within your VB Editor screen, enter 'DisableShift' within your Immediate window and hit Enter. You will then receive a message advising that the Shift Key has been Disabled.

To re-enable the Shift key, you will once again need to return to the VB Editor screen, enter 'EnableShift' within your Immediate window and hit Enter. You will again receive a message in your Immediate window advising the Shift Key has been Enabled.

NOTE: This is not a fool proof way to enable and disable the Shift Key, but if you are deploying a database to users who are not proficient with MS Access and VBA, it should be helpful in preventing users from accessing the VB Editor and/or Navigation Pane within your database.

Access Error Codes (Form.Error, DataErr)

Check if Table Exists in Current DB

Simply place this code as a Public Module that can be called by any other procedure. When calling the code, add in the name of the table you want to look up within the parenthesis. The Code returns a True/False value on whether or not a table already exists. This is helpful when needing to determine if a table needs to be deleted/purged or if a table already exists before performing additional code.

Create Text Delimited File in Access Vba

This is worth pointing out:

 Wholeline = Wholeline & aRR(i, j) & Sep

Because recordsets dump to arrays transposed, you will have to read it to the text file backwards. This is actually kind of handy if youre working with dynamic arrays, as it is already transposed for you, so redim'ing the "row count" can be done before any heavy lifting.

Also worth nothing:

You can easily transpose youre array by dumping it into a new one line by line using this syntax:

    Dim xaRR() As String
    ReDim xaRR(q, z)
    xaRR(j, i) = aRR(i, j)

this isnt too relevant to my post, but its worth pointing out.