Implementing a Daily Reminders Screen

A typical example might be the humble Daily Reminders screen implemented in many applications. This screen usually pops up when the application starts up, to remind users of overdue accounts, tasks they need to perform that day, or any number of things of which they need to be made aware.

Having such a facility can be of great benefit to both the organization and the user, but some users prefer to display this screen when they want to. Having the screen pop up every time they start the application can be a real nuisance, particularly if it takes some time to process and sort the information that's displayed. The resolution here is to offer the user the capability to have the screen pop up or not.

To do this, you need to store a Boolean value somewhere. You can store it in a table, but if your database is built on a client/server model, with the tables stored on a server share, the setting would affect all users. Storing the value in a local table would mean all users of that particular computer would similarly share the same setting. The answer is to store the value in the Registry so each user can set his own preferences.

To implement that behavior, start by creating an Overdue Accounts form containing a list box, command button, and check box, as shown in Figure 20-5. (This example simply adds the company names and amounts to the list box's RowSource property, but a real form would probably populate it using a recordset.)

Figure 20-5

Then, add the following code to the check box's Click() event.

Private Sub chkShowAtStartup_Click() Dim strApp As String

'Assuming you have set the Application Title property in the Access Options dialog strApp = CurrentDb.Properties("AppTitle") 'Save the new checkbox setting.

SaveSetting strApp, "Settings", "Show at Startup", _ Me.chkShowAtStartup

End Sub

In this code, it doesn't matter if the user doesn't click the check box because the form displays whether the setting exists or not. But if he does click it, the appropriate setting will be immediately saved to the Registry.

Of course, you need to set the initial value of the check box when the form displays, so add the following code to the form's Load event.

Private Sub Form_Load()

Dim strApp As String

'Assuming you have set the Application Title property dialog strApp = CurrentDb.Properties("AppTitle")

in the Access Options

'Set the checkbox value.

'If the setting doesn't exist, assume a default True.

Me.chkShowAtStartup = GetSetting(strApp, "Settings", ' End Sub

'Show at Startup", True)

Then all you have to do is modify your startup code to decide whether to show this form:

Dim strApp As String Dim booShowForm As Boolean

'Assuming you have set the Application Title property in the Access Options dialog strApp = CurrentDb.Properties("AppTitle")

booShowForm = GetSetting(strApp, "Settings", "Show at Startup", True)

'If the setting doesn't exist, it is probably the 'first time the user has launched the application, 'so show the form. If booShowForm = True Then

DoCmd.OpenForm "frmOverDueAccts" End If

0 0

Post a comment