Online Book Reader

Home Category

Access Cookbook - Ken Getz [94]

By Root 1966 0
looks at this information only once, when it loads the properties sheet for the first time. Once it has loaded the properties sheet, it doesn't look at these values again. Every time you leave design mode Access stores information about the properties sheet, so if you're going to try to set these values for the next time you start Access, make sure you do it when there's no report open in design mode. Otherwise, Access will override your settings when it saves them itself.

To use this technique for forms, use option "_24" instead. It's not nearly as useful with forms as it is with reports, however, because in older versions of Access you can open hidden forms but not hidden reports.

NEVER TURN OFF THE SCREEN WITHOUT AN ERROR HANDLER!

Though this same advice goes for using Application.Echo or Form.Painting, it's especially true for using LockWindowUpdate. Any time you turn off the screen display, you absolutely must include an error handler in your routine that will immediately reenable screen updates if an error occurs. Sooner or later, a runtime error will occur, and your code must react to this and clean up. Users tend to do unpleasant things, such as rebooting their computers, when their screens stop dead (that's what would happen if an error occurred while you had screen updates turned off ). This can be detrimental to their data and to your application, so never consider turning off the screen unless you also include an error handler to turn it back on.

As an example of an error handler that resets screen updates, the code executed by frmLockScreen handles errors by using the normal exit route from the routine:

Private Sub cmdOpenReports_Click( )

Dim intI As Integer

Dim intSuccess As Integer

On Error GoTo HandleErr

If Me.chkHideUpdates Then

If Me.chkUseAPI Then

Call acbShowUpdatesAPI(False)

Else

Call acbShowUpdates(False)

End If

End If

For intI = 1 To 3

Call acbOpenReport("rptReport" & intI, acDesign)

Next intI

For intI = 1 To 3

DoCmd.Close acReport, "rptReport" & intI

Next intI

ExitHere:

If Me.chkHideUpdates Then

If Me.chkUseAPI Then

Call acbShowUpdatesAPI(True)

Else

Call acbShowUpdates(True)

End If

End If

Exit Sub

HandleErr:

MsgBox Err.Number & ": " & Err.Description

Resume ExitHere

End Sub

If an error occurs while this subroutine is active, the code will jump to the HandleErr label and from there will resume at the ExitHere label. The code will re-enable screen updates and then exit the routine. Your own code may not look exactly like this, but you must handle errors so that the screen never remains locked up when an error occurs.

See Also


For more information on working with the Windows API, see Chapter 11.

4.5. Find out What Language Version of Access Is Installed


Problem


You distribute your applications in several countries, and your users have different internationalized versions of Access installed. You'd like your applications to be able to make decisions based on the installed version of Access. How can you find out which language version of Access is currently running?

Solution


In older versions of Access, you had to use an API call to get this information. However, starting with Access 2000, it is possible to retrieve language information using the Microsoft Office Object Library. This solution demonstrates how you can gather the language information you need.

Load and run the form frmLanguage in 04-05.MDB. As it loads, it calls the necessary functions to determine the currently running language version of Access. Figure 4-10 shows the form after it's been loaded into a retail U.S. English version of Access.

Figure 4-10. frmLanguage indicates the language version of Access that's running

To include this functionality in your own applications, follow these steps:

Import the module basFileLanguage from 04-05.MDB into your own application. This module includes constants representing the seven most commonly used languages and their related intrinsic constants and values.

Declare a long integer variable, lngLanguage. When your

Return Main Page Previous Page Next Page

®Online Book Reader