Compile error-ambiguous name detected :sleep (1 Viewer)

gianniskar

New member
Local time
Tomorrow, 01: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]
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 18:17
Joined
Apr 27, 2015
Messages
6,412
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.
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:17
Joined
Sep 21, 2011
Messages
14,528
Is that all you copied?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:17
Joined
May 21, 2018
Messages
8,641
This means you have two things with the same name. Since you pasted you probably have two public functions named sleep in two modules.
 

gianniskar

New member
Local time
Tomorrow, 01:17
Joined
Feb 27, 2020
Messages
24
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

  • access.zip
    6 KB · Views: 125

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:17
Joined
May 21, 2018
Messages
8,641
wherever you call sleep modify the code to
basShared.sleep

Make sure you do not have a module called Sleep
 

vba_php

Forum Troll
Local time
Today, 17:17
Joined
Oct 6, 2019
Messages
2,880
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.
 

gianniskar

New member
Local time
Tomorrow, 01:17
Joined
Feb 27, 2020
Messages
24
i think the problem is the module mdlGeneral.if i deleted no error.but i dont want remove
 

Attachments

  • mytest.zip
    1,014.8 KB · Views: 106

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:17
Joined
May 21, 2018
Messages
8,641
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.
 

gianniskar

New member
Local time
Tomorrow, 01:17
Joined
Feb 27, 2020
Messages
24
because i am confused now.

First can you tell me witch are 2 modules with same name?
 
Last edited:

gianniskar

New member
Local time
Tomorrow, 01:17
Joined
Feb 27, 2020
Messages
24
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?
 

vba_php

Forum Troll
Local time
Today, 17:17
Joined
Oct 6, 2019
Messages
2,880
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.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:17
Joined
May 21, 2018
Messages
8,641
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.
 

gianniskar

New member
Local time
Tomorrow, 01:17
Joined
Feb 27, 2020
Messages
24
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: 122

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:17
Joined
May 21, 2018
Messages
8,641
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'.
 

gianniskar

New member
Local time
Tomorrow, 01:17
Joined
Feb 27, 2020
Messages
24
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
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:17
Joined
May 21, 2018
Messages
8,641
Is there a reason you cannot simply do a "Find" as I asked and get rid of the second Sleep procedure?
 

gianniskar

New member
Local time
Tomorrow, 01:17
Joined
Feb 27, 2020
Messages
24
sorry.. i found that results about "sleep"
 

Attachments

  • result1.png
    result1.png
    114.5 KB · Views: 110
  • result2.png
    result2.png
    147 KB · Views: 117
  • result3.png
    result3.png
    102.9 KB · Views: 107
  • result4.png
    result4.png
    98.2 KB · Views: 99

CJ_London

Super Moderator
Staff member
Local time
Today, 23:17
Joined
Feb 19, 2013
Messages
16,703
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

Top Bottom