Isloaded Compile Error

Serious Sam

New Member
Joined
Jan 19, 2005
Messages
30
Hello,
I have copied a piece of code from the Time Billing template, adapted it slightly for my database, abut can't get it to work.

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmSummaryCriteria", , , , , acDialog, "rptTimeCards"
If Not IsLoaded("frmSummaryCriteria") Then
Cancel = True
End If
End Sub

When I open the report rptTimeCards, I want the frmSummaryCriteria to open.
Instead, on the bolded line above I get:
Compile Error: Sub or Function not defined

I must need to define something, but I can't work out what the Time Billing template has that I don't. The code I copied is:

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog, "Clients Billings by Project"
If Not IsLoaded("Report Date Range") Then
Cancel = True
End If
End Sub

Any help much appreciated
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Serious Sam

New Member
Joined
Jan 19, 2005
Messages
30
IsLoaded Solution

I found a module in the Time Billing database that I did not have in my database. It is listed below.
I don't fully understand it, but I know it's needed to make the isloaded code work. If someone wants to give a laymans explanation of what's below, please feel free.

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
Sam,

Here's the quick rundown. This line is checking to see if the form you are interested in is loaded:
Code:
If Not IsLoaded("frmSummaryCriteria") Then

What it does, is call the custom function IsLoaded, which checks whether frmSummaryCriteria is loaded. The rest of the routine after that line dictates what to do with the result: If the form has not loaded successfully,
Code:
 Cancel = True
will abort the process.

The IsLoaded function itself uses some special calls to determine if:
1. The form has been loaded somehow, and
2. It is not just in Design view.

If both of these tests pass, then the function returns IsLoaded = True.

Back in the original procedure, that is what the If Not IsLoaded... line is testing. In this case it's looking for IsLoaded = False.

Hope that helps

Denis
 

Forum statistics

Threads
1,136,354
Messages
5,675,303
Members
419,560
Latest member
g3org

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top