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

gianniskar

New member
Local time
Today, 05:26
Joined
Feb 27, 2020
Messages
24
could you help me wich funtion change name to "mysleep"?
 

gianniskar

New member
Local time
Today, 05:26
Joined
Feb 27, 2020
Messages
24
well i change again private Sub mySleep(sngTime As Single) to Public Sub mySleep(sngTime As Single) in a module BasShared and i changed name then i changed from form frmEntry_Main the
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

to
Public Sub HotSpotClick(sControlName As String)
On Error GoTo PROC_ERR

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

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox Err.Description
Resume PROC_EXIT

End Sub

am i wrong?
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 03:26
Joined
Feb 19, 2013
Messages
16,701
you have not addressed this issue

Sleep 0.1

which is calling this function

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

so you are trying to sleep for 0.1 milliseconds. As previosly advised, the minimum you can have is 1 millisecond because Longs are whole numbers. So you need

sleep 1

note there are 1000 milliseconds in a second so this is a very very very short period of time

the same goes for your function

mySleep 1
 

gianniskar

New member
Local time
Today, 05:26
Joined
Feb 27, 2020
Messages
24
pease check my attached file.i believe i made all changes
 

Attachments

  • mytest_new (2).zip
    861.9 KB · Views: 106

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:26
Joined
May 7, 2009
Messages
19,248
you can safely comment out or remove the Sleep API from mdlGeneral since it has same
functionality as the one in module BasShared.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:26
Joined
May 7, 2009
Messages
19,248
it only make your code Pause for a while so as to give way for other system events to fire.
 

gianniskar

New member
Local time
Today, 05:26
Joined
Feb 27, 2020
Messages
24
ok.So in my last attached file,is it wrong the changes who i made sleep-->mysleep?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 03:26
Joined
Feb 19, 2013
Messages
16,701
don't understand what you are asking or who's post you are responding to.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 03:26
Joined
Feb 19, 2013
Messages
16,701
before uploading - does it now do what you want?
 

gianniskar

New member
Local time
Today, 05:26
Joined
Feb 27, 2020
Messages
24
yes i have 1 another error .Can you unzip now and check mysleep function?
 

Attachments

  • mytest_new.zip
    422.9 KB · Views: 94
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 03:26
Joined
Feb 19, 2013
Messages
16,701
gianni - you make it very time consuming for people to help you.

your mysleep function looks fine to me - however my point has been made several times before - sleeping for one thousandth of a second is hardly worth doing.

so far as I can see the errors are due to missing forms and modules, can't advise any more than that - the error messages tell you what is missing.

The code looks like it has been created by someone other than yourself - either a template or from one or more forums/websites - and looks very old (access 2003 or earlier) and I suspect you have taken modules from different places and trying to combine them in some way. My point is, you need to take the time to understand what the code is doing.

I strongly advise you put Option Explicit at the top of each module (including form modules) just below Option Compare Database. Then compile your code (in the vba menu select Debug>Compile) which will highlight most of the errors you have before you need to open a form. You can make this happen automatically for new modules by going to Tools>Options on the vba menu and on the editor tab ensure the 'require variable declaration' is ticked.
 
Last edited:

gianniskar

New member
Local time
Today, 05:26
Joined
Feb 27, 2020
Messages
24
ok .Sorry for this.Thanks for any help who gave to me all of you
 

Gasman

Enthusiastic Amateur
Local time
Today, 03:26
Joined
Sep 21, 2011
Messages
14,524
[FONT=arial]gianniskar[/FONT],

Open the VBA editor with Alt + F11
Select Tools/Options

Tick the checkbox 'Require Variable Declaration' and then click OK button.

This will put 'Option Explicit' in all future code for you, but you will need to manually enter for code already created.

As CJ_London indicated, enter once at the top of each code module (Form,Report,Module) etc.

HTH
 

Users who are viewing this thread

Top Bottom