Hi there.
I have the following code in the open event of a form. Most of it sets
or checks the value of certain variables so that the form opens
properly. It also sets the recordsource for the form. It all works
correctly. However, It runs very slowly and it takes a couple of seconds
for the form to open. Is there anything I can do to speed it up that
won't change the functionality? Or do I have to find otherways of
accomplishing what this form does?
--Code Start--
Private Sub Form_Open(Cancel As Integer)
streditmode = ""
If Not IsNull(Me.OpenArgs) Then
streditmode = Me.OpenArgs
DoCmd.Maximize
Else
DoCmd.CancelEvent 'Cancel opening of the form and give the user an
error message
FormattedMsgBox "Error - Open Mode not passed to form. This form
must be opened through code.@ If you opened this form from the database
window, please don't do this. Otherwise, Please report this error to the
Program Administrator@", vbCritical, "Error"
End If
If cbxSelectContact.Visible Then
cbxSelectContact.SetFocus
If (streditmode = "E" Or streditmode = "B") And Not Me.FilterOn Then
FormattedMsgBox ("Please select a contact before you do anything
else."), vbInformation + vbOKOnly, "Selection Required"
btnViewBusinessCard.Caption = "View Business Card"
Else
btnViewBusinessCard.Caption = "Add Business Card"
CbxSalutation.SetFocus
End If
If UCase(streditmode) = "B" Then 'Browse mode, so lock the appropriate
controls!
If Not LockControlsForBrowse(Me) Then
DoCmd.CancelEvent 'Don't continue to open the form!
FormattedMsgBox "An error occured while setting up this form
for Browse Mode. @Please report this error to the Program
Administrator@", vbCritical, "Error"
End If
End If
If streditmode = "A" Then
Form.Caption = "Contacts - Add Mode"
cbxSelectContact.Visible = False
Box94.Visible = False
cmdImportContacts.Visible = True
cmdImportContacts.Left = 0.079
ElseIf streditmode = "E" Or streditmode = "B" Then
If streditmode = "E" Then
Form.Caption = "Contacts - Edit Mode"
Else
If streditmode = "B" Then
Form.Caption = "Contacts - Browse Mode"
End If
End If
cmdImportContacts.Visible = False
cbxSelectContact.Visible = True
Box94.Visible = True
btnViewBusinessCard.Visible = True
End If
End If
End Sub
--Code End--
One of the things I was thinking was I could use Select Case instead of
if-then statements for setting all the streditmode arguments. Would this
speed up the form?
Thank you
Colin
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!