Ambiguous Name Detected

coolcatkelso

Registered User.
Local time
Today, 18:10
Joined
Jan 5, 2009
Messages
279
Hiya guys

Just went to compile Dbase to make accde and got the error

Ambiguous Name Detected - IsLoaded

Code:
Private Sub Form_AfterUpdate()
If IsLoaded("Workorders by Customer") Then
  Forms![Workorders by Customer].[Quotes by Customer Subform].Form.Requery
End If
End Sub

I think if I remember its something to do with something already declared or something, but not 100% sure, and don't know how to fix
________
The cigar boss
 
Last edited:
Cool,

Do you possibly have your IsLoaded function in a module that is ALSO called
IsLoaded?

Or do you possibly have the same function occurring twice (even in different
modules)?

Wayne
 
No don't have any module named Isloaded

Not sure if the IsLoaded is in any other module

Its being called in from a form if that helps lol?

I've got about 21 Modules, you need me to go through them all?

I did find this one in a module called Utils - Function IsLoaded(ByVal strFormName As String) As Boolean
And this one in Global Code - Function IsLoaded(ByVal strFormName As String) As Integer
________
Kid zoloft
 
Last edited:
Kelso,

The easy way is to get in one of your modules and select --> Compile

It will show you which modules have the duplicate definition ... as well as
any other errors you might have. Note the module name when the
compiler reports an error.

You will need a clean compile to make your accde.

Wayne
 
So what should I do with the Isloaded comments?

Do I keep both these

Function IsLoaded(ByVal strFormName As String) As Boolean

Function IsLoaded(ByVal strFormName As String) As Integer

and remove this one

Private Sub Form_AfterUpdate()
If IsLoaded("Workorders by Customer") Then
Forms![Workorders by Customer].[Quotes by Customer Subform].Form.Requery
End If
End Sub
________
Uggs
 
Last edited:
Kelso,

Your code appears the function to return a Boolean, therefore I'd comment
out this one:

Function IsLoaded(ByVal strFormName As String) As Integer

But do you have code that expects an Integer return value?

Wayne
 
I have no Idea lol

This is my Global Code

Code:
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

And this is the Utils Code

Code:
Option Compare Database
Option Explicit
Function IsLoaded(ByVal strFormName As String) As Boolean
 ' 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
________
Yamaha Drums Specifications
 
Last edited:
I deleted the Code from Utils Module -
Function IsLoaded(ByVal strFormName As String) As Boolean

And all the other Isloaded works fine, no compile error.. So it defo this one thats the issue but dunno what to do with it
________
Vapor tower vaporizer
 
Last edited:
Don't know if this is right or not, but I change it from

Function IsLoaded(ByVal strFormName As String) As Boolean

to This

Private Function IsLoaded(ByVal strFormName As String) As Boolean

Compiled it, and no errors?
________
DESIGN HOST
 
Last edited:
Kelso,

You MUST have it as a Public Function in order for your forms to see it.

It must be Public.

Wayne
 
Kelso,

You MUST have it as a Public Function in order for your forms to see it.

It must be Public.

Wayne
If declared like:

Function XXXXXX()

it is public as well as

Public Function XXXXXX()

It is only private if

PRIVATE Function XXXXXX()

is declared.
 
Just do a global Find on ‘IsLoaded’.

Comment out any Function that reads as: -
Function IsLoaded(ByVal strFormName As String) As Boolean

When you only have one Function remaining called: -

Function IsLoaded(ByVal strFormName As String) As ... “Whatever”

Change it to: -
Public Function IsLoaded(ByVal strFormName As String) As Integer

Then place the cursor on the word ‘IsLoaded’ and press the <F1> key.
Read about it and decide if you still want to use it at all.
 
Code:
Option Explicit
Option Compare Text


Private Sub Form_Load()
    Dim srtSQL As String
    
    [color=green]' Set Function IsLoaded() to return type as Boolean[/color]
    srtSQL = "WHERE MyBooleanField = " & IsLoaded(Me.Name)
    [color=green]' What do you get?[/color]
    MsgBox srtSQL   [color=green]' WHERE MyBooleanField = True[/color]
    
    
    [color=green]' Set Function IsLoaded() to return type as Integer[/color]
    srtSQL = "WHERE MyBooleanField = " & IsLoaded(Me.Name)
    [color=green]' What do you get?[/color]
    MsgBox srtSQL   [color=green]' WHERE MyBooleanField = -1[/color]
    
    
    
    [color=green]' Now give that code to someone running, for example, the Dutch version of Access.
    
    
    
    ' Set Function IsLoaded() to return type as Boolean[/color]
    srtSQL = "WHERE MyBooleanField = " & IsLoaded(Me.Name)
    [color=green]' What do you get?[/color]
    MsgBox srtSQL   [color=green]' WHERE MyBooleanField = Waar[/color]
    
    
    [color=green]' Set Function IsLoaded() to return type as Integer[/color]
    srtSQL = "WHERE MyBooleanField = " & IsLoaded(Me.Name)
    [color=green]' What do you get?[/color]
    MsgBox srtSQL   [color=green]' WHERE MyBooleanField = -1[/color]
    
    
    [color=green]' The point is that the string: -
    ' WHERE MyBooleanField = Waar
    ' can't be used within an SQL string because SQL strings require English not Dutch.
    ' So the one that fails is when the return value is set to the Boolean value, meaning: -
    ' Public Function IsLoaded(ByVal strFormName As String) As Boolean
    ' will fail if the return data type as 'True' or 'False' is interpreted by the
    ' language version as anything other than 'True' or 'False', as in this case
    ' the Dutch version as 'Waar' or 'Onwaar', respectively.
    '
    ' But: -
    ' Public Function IsLoaded(ByVal strFormName As String) As Integer
    ' returns to the SQL string, in this case, 'WHERE MyBooleanField = -1'
    ' That survives the natural language interpretation because -1 and 0 are
    ' understood by SQL.
    '
    ' Please don't use a return type as Boolean unless you are prepared for the worst
    ' debugging session you ever came across, and incidentally, can't see.[/color]

End Sub
 

Users who are viewing this thread

Back
Top Bottom