How to Set Program to Close Automatically

Set Program to Close Automatically MS Access program can be closed automatically if there is no activity. In this How To, the method of detecting the idle on active form and active control will be used. The idle time will count when a new form is opened or get focus and/or a control is changed within the active form. There are three steps to make this happen. Create a Detect Idle Time form Apply the VB code on the Timer event procedure Create Macro to load the Detect Idle Time…

Read More

Function Get Table List : MS Access

Function/SQL Get Table List from MS Access There are two ways to get a table list and put them into the combo box. Method 1: Use a System Object as a Row Source of Combo box 1. Create a combo box 2. Set the Row Source Type to “Table/Query” 3. Under the Row Source of the combo box Data Property Sheet, add the SQL Statement to select only the table name SQL Statement: SELECT MSysObjects.name AS TableName FROM MSysObjects WHERE (((MSysObjects.type)=1) AND ((MSysObjects.Flags)=0)) ORDER BY MSysObjects.name; MSysObjects.Type = 1 for…

Read More

How to Generate Email List from Excel

How to Get Email List from MS Excel using MS Access There are many ways to get the email list from the Excel list for sending email to those people. Many people may just copy the email from Excel then paste it on the Outlook new mail one by one. You cannot copy one time from the column C shown on the picture below then paste it on the Outlook mail To, because Outlook needs a semi-colon(;) between each email address. Also there is a blank email for some customers…

Read More

Function Open Image File – VBA

We use this function to open the image file. You can put this function in the module then call it anywhere in your Access database. Function OpenImageFile(ByVal strFilePath As String) As String  If IsNull(strFilePath) Then     MsgBox “File Not Found”, vbExclamation, “Action Cancelled”         Else         Application.FollowHyperlink strFilePath    End If End Function How to Use It: You can call this function on any form like: Dim myPath as string myPath = “C:\Users\Test\Downloads\report.png” call OpenImageFile(myPath)  

Read More

Function Backup File

Function Backup file You will need to put this function under the Module then call it on the button On Click Event Function BackupFile() As Boolean Dim Source As String Dim Target As String Dim retval As Integer Source = CurrentDb.Name ‘change your backup location here Target = “Z:\My Apps\Backups\YourFielName” Target = Target & Format(Date, “mm-dd”) & ” ” Target = Target & Format(Time, “hh-mm”) & “.accdb” ‘ create the backup retval = 0 Dim objFSO As Object Set objFSO = CreateObject(“Scripting.FileSystemObject”) retval = objFSO.CopyFile(Source, Target, True) Set objFSO =…

Read More

How to get data from InputBox() function

How to use InputBox() function Get input data from the InputBox() and links to CustomerID in database  1. Create a form and insert the button and name it as “btnCustomer”      2. In this example, we will open Customer form and showing the Customer record having a customerID matching the CustomerID entered into the InputBox(). Put the VBA code under the Click Event of customer button. Private Sub btnCustomer_Click() Dim stDocName As String Dim getCustomerID As String         getCustomerID = InputBox(“Please enter your customerID”, ” CustomerID Needed”)        If getCustomerID =…

Read More