Function Name problem

  • Thread starter TotallyConfused
  • Start date
T

TotallyConfused

I just finished working on a form where I had to add a function that is
Module 2 below. However, I had in my database a Utilities Module (copy
below). When I run one of my form/report I get the following message: "The
expression contains an ambiguous name. You may have two or more functions
with the same name in different modules. Rename the function so that each
one has a unique name." At first I thought it was the same function, but
they are different. How can I fix this with jeopardizing my database?
thank you in advance for any help you can provide.


Utilities Module

Option Compare Database
Option Explicit

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



Module 2

Option Compare Database

Function IsLoaded(ByVal strFormName As String) As Boolean

Dim oAccessObject As AccessObject
Set oAccessObject = CurrentProject.AllForms(strFormName)

If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then
IsLoaded = True
End If
End If
 
F

fredg

I just finished working on a form where I had to add a function that is
Module 2 below. However, I had in my database a Utilities Module (copy
below). When I run one of my form/report I get the following message: "The
expression contains an ambiguous name. You may have two or more functions
with the same name in different modules. Rename the function so that each
one has a unique name." At first I thought it was the same function, but
they are different. How can I fix this with jeopardizing my database?
thank you in advance for any help you can provide.

Utilities Module

Option Compare Database
Option Explicit

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

Module 2

Option Compare Database

Function IsLoaded(ByVal strFormName As String) As Boolean

Dim oAccessObject As AccessObject
Set oAccessObject = CurrentProject.AllForms(strFormName)

If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then
IsLoaded = True
End If
End If

The NAME of each function is the same (IsLoaded).
Change either one of them to
Function IsLoaded1(ByVal strFormName As String) As Boolean (Or
Integer)
and call it using
If IsLoaded1("FormName") Then .....
 
J

Jeanette Cunningham

Hi,
both of the functions do the same thing. You need to delete one of them,
save and compile.
Jeanette Cunningham
 
T

TotallyConfused

Thank you for responding. So it is safe to keep the most current one and
will it will not mess anything else in my database?
 
J

Jeanette Cunningham

Yes, they both do the same thing and both have the same name. If you want to
use the belt and braces approach, just comment out one of the functions,
save and compile. This way the second one is always there, if you want to
use it instead, you can uncomment it and comment out the previous one.

Jeanette Cunningham
 
J

Jeanette Cunningham

Hi,
I forgot to add this: create a backup of your database frequently and save
the backups. If something goes wrong in the future, which often happens when
you are developing, you just go back to the latest backup and you only have
to re-do the new things since the last backup.

Jeanette Cunningham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top