Compile error-ambiguous name detected :sleep

gianniskar

New member
Local time
Today, 08:17
Joined
Feb 27, 2020
Messages
24
hi. i have this code from application who i copied and put in my database.On original application when compile database i have not error but when i compile in my database h iave this error "ambiguous name detected :sleep"

......

'******************************************************************************************
Public Sub HotSpotClick(sControlName As String)

On Error GoTo PROC_ERR

Me.Controls(sControlName).SpecialEffect = 2
Sleep 0.1
Me.Controls(sControlName).SpecialEffect = 3
DoEvents

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox Err.Description
Resume PROC_EXIT

End Sub


[/CODE]
 
The Sleep Function is I beleive, an API call that you have to declare in a module:

Code:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Then it should work.
 
Is that all you copied?
 
This means you have two things with the same name. Since you pasted you probably have two public functions named sleep in two modules.
 
thanks all for your answers and sorry for any mistake about my english languange.

1) i cant coy all code inside post because system not let me doing this
2)yes i searched in google about this error
3) no i created new database and step by step copy old database with access-external links-access
please look up the attached file.it has 1 form class and the module.Error is in the form class
 

Attachments

wherever you call sleep modify the code to
basShared.sleep

Make sure you do not have a module called Sleep
 
upload an entire file with the class module inside of it. the word SLEEP does not appear one time in your visual basic file you uploaded. nor does the word appear in the *huge* class module file you uploaded. there are quite a few routines in there.
 
i think the problem is the module mdlGeneral.if i deleted no error.but i dont want remove
 

Attachments

As I previously stated you have the same procedure named Sleep in two different modules. I am not sure how to be more clear. So in that module you have a public procedure called sleep. The prior solution I posted works as well. Again not sure how to be more clear.
 
because i am confused now.

First can you tell me witch are 2 modules with same name?
 
Last edited:
ok in a "BasicShare" module i change

public Sub Sleep(sngTime As Single)
On Error GoTo PROC_ERR

Dim sngStart As Single
sngStart = Timer
Do
DoEvents
Loop Until sngStart + sngTime < Timer

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox Err.Description
Resume PROC_EXIT

End Sub

to

Private Sub Sleep(sngTime As Single)
On Error GoTo PROC_ERR

Dim sngStart As Single
sngStart = Timer
Do
DoEvents
Loop Until sngStart + sngTime < Timer

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox Err.Description
Resume PROC_EXIT

End Sub

Is it ok?
 
for me, your file keeps automatically searching for MSORUN.DLL. it crashes everytime I open the VBA window. I searched for the term "sleep" in your code and you have some API calls in there but I didn't see anything that was ambiguous in nature.
 
In vba. Use "Edit, Find" and search for "sleep". If you have two procedures in you project with the same name you get "Ambiguous Name Detected".
Since it works when you delete mdlGeneral it works.
So obviously in mdlGeneral you have a procedure named sleep. You also have it somewhere else in your project.
 
me not crashes.
so as not to confuse you as i said change to private sub sleep .Is that ok or its wrong?

and after changed that ,start to compile again and now i have another error
 

Attachments

  • variable not found.png
    variable not found.png
    97.3 KB · Views: 191
You can make it private, but now when you call the method you will need to add the module name
yourModuleName.sleep

The reason it compiles is that you still have another public "Sleep" in you project somewhere. However, since this one is now private you no longer have an ambiguous name problem.

However, the better solution is to have one and only one public function called "sleep'.
 
Well no i have not any error when i compile database. I want to tell me if changes which i did ,is it ok

1) Compile error "ambiguous name detected :sleep"
Changed from module "BasShared" the sub public Sub Sleep(sngTime As Single) to private Sub Sleep(sngTime As Single)



2)Compile error "variable not defined"
I added to top "Public Const IDC_ARROW = 32512" in module "mdlGeneral
 
Is there a reason you cannot simply do a "Find" as I asked and get rid of the second Sleep procedure?
 
sorry.. i found that results about "sleep"
 

Attachments

  • result1.png
    result1.png
    114.5 KB · Views: 164
  • result2.png
    result2.png
    147 KB · Views: 170
  • result3.png
    result3.png
    102.9 KB · Views: 158
  • result4.png
    result4.png
    98.2 KB · Views: 151
the other 'Sleep' is an API call in mdlGeneral

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

as not to confuse you as i said change to private sub sleep .Is that ok or its wrong?
Your call to sleep is in a form. If you change your sub to Private it can only be accessed by other subs and functions in that module. So your form is trying to use the sleep sub in mdlGeneral. You should change the name of your function to something like mySleep

Your call is passing a parameter of 0.1, 0.01 or iVal (no idea what that value might be) either way 0.1 will fail because both your versions require a whole number (long in the case of the API and single in the case of your sub).
 

Users who are viewing this thread

Back
Top Bottom