Compile error-ambiguous name detected :sleep

could you help me wich funtion change name to "mysleep"?
 
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:
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
 
you can safely comment out or remove the Sleep API from mdlGeneral since it has same
functionality as the one in module BasShared.
 
it only make your code Pause for a while so as to give way for other system events to fire.
 
ok.So in my last attached file,is it wrong the changes who i made sleep-->mysleep?
 
don't understand what you are asking or who's post you are responding to.
 
before uploading - does it now do what you want?
 
yes i have 1 another error .Can you unzip now and check mysleep function?
 

Attachments

Last edited:
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:
[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

Back
Top Bottom