Scrolling text while moving Mouse/cursor over button on form

mba_110

Registered User.
Local time
Yesterday, 20:02
Joined
Jan 20, 2015
Messages
280
Hi everyone,

I need your help to determined the procedure for scrolling text message for my form while moving cursor over button and labels.

my form name is frmDataEntry_Nav and i am using access 2007-2010

Thanks & regards
MA
 
Controls have a mousemove event and forms have a timer.

Create a new form add three buttons btnReleaseTheNukes, btnCloseBunkerDoors, btnOpenBunkerDoors and a label lblHelpMessage and paste the below into the form's module.

Code:
Private Type Message
    msg As String 'the message to display
    length As Byte 'number of characters to display
    pos As Integer 'the current start position
End Type

Dim msg As Message

Private Sub Form_Open(Cancel As Integer)
    lblHelpMessage.BorderStyle = 1
    lblHelpMessage.TextAlign = 2
End Sub

Private Sub SendMsg(m As String)
    If Not msg.msg = m Then
        msg.msg = m
        msg.length = 8
        msg.pos = 0
        Me.TimerInterval = 100
    End If
End Sub

Private Sub Form_Timer()
    Dim s As String
    s = String(msg.length - 1, " ") & msg.msg
    msg.pos = msg.pos + 1
    If msg.pos > Len(s) Then
        TimerInterval = 0
        lblHelpMessage.Caption = ""
        Exit Sub
    End If
    lblHelpMessage.Caption = Mid(s, msg.pos, msg.length)
End Sub


Private Sub btnReleaseTheNukes_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SendMsg "Click to fire all active warheads at designated target(s)"
End Sub

Private Sub btnCloseBunkerDoors_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SendMsg "Oops."
End Sub

Private Sub btnOpenBunkerDoors_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SendMsg "Radiation levels not too bad. Do you feel lucky punk?"
End Sub
 
I am sorry but things are not clear for me, kindly tell me exactly where you want to place this on form open event or load or current.

I am new to vba also i need to ask, blank label won't be placed anywhere it has to be write something in it otherwise it will disappear.

Sorry for asking stupid question but i really dont know.
 
Instructions are provided in the post.
To make a label blank set its caption to a space.
 
I have Seven buttons, and the label of contained text should show while moving cursor on button only.

I have tried your code but not working, below is all my code including your one is here.

Code:
 Option Compare Database
Private message As String


Private Sub btnemployees_Click()
DoCmd.OpenForm "frmEmployees_Nav"

End Sub

Private Sub btnContract_Click()
DoCmd.OpenForm "frmContracts_Nav"

End Sub

Private Sub btnPayroll_Click()
DoCmd.OpenForm "frmPayroll_nav"
End Sub

Private Sub btnInsurance_Click()
DoCmd.OpenForm "frmInsurance_Nav"
End Sub

Private Sub btnPayments_Click()
DoCmd.OpenForm "frmPayments_Nav"

End Sub

Private Sub btnReports_Click()
DoCmd.OpenForm "frmreportcenter_Nav"
End Sub

Private Sub Form_Load()
Me.Text59 = Environ("Username")
End Sub
       
Public Sub Form_Open(Cancel As Integer)
message = "Welcome to Employee Management System .      "
End Sub

Private Sub Form_Timer()
txtMarquee = message
'get the first letter
Dim firstcharacter As String
firstcharacter = Left(txtMarquee, 1)

'remove first character
message = Mid$(message, 2, Len(message) - 1)
'put first character at the end of the message
message = message + firstcharacter

End Sub

Private Type message
    msg As String 'the message to display
    length As Byte 'number of characters to display
    pos As Integer 'the current start position
End Type

Dim msg As message

Private Sub Form_Open(Cancel As Integer)
    lblHelpMessage.BorderStyle = 1
    lblHelpMessage.TextAlign = 2
End Sub

Private Sub SendMsg(m As String)
    If Not msg.msg = m Then
        msg.msg = m
        msg.length = 8
        msg.pos = 0
        Me.TimerInterval = 250
    End If
End Sub

Private Sub Form_Timer()
    Dim s As String
    s = String(msg.length - 1, " ") & msg.msg
    msg.pos = msg.pos + 1
    If msg.pos > Len(s) Then
        TimerInterval = 0
        lblHelpMessage.Caption = ""
        Exit Sub
    End If
    lblHelpMessage.Caption = Mid(s, msg.pos, msg.length)
End Sub

Private Sub btnPayroll_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SendMsg "Click to fire all active warheads at designated target(s)"
End Sub

Private Sub btnContract_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SendMsg "Oops."
End Sub

Private Sub btnInsurance_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SendMsg "Radiation levels not too bad. Do you feel lucky punk?"
End Sub

Please have a look where the things are went wrong.

the error message is coming with

" The expression on open you entered as the event property setting produced the following error: ambiguous name detected: form_open

*The expression may not in the name of a macro, the name of a user-defined function, or [Event Procedure]

*There may have been an error evaluation the function, event, or macro.
 

Users who are viewing this thread

Back
Top Bottom