Question:

How to run a marquee in MS Access?

by Guest65325  |  earlier

0 LIKES UnLike

I want to run a marquee on main form.

 Tags:

   Report

2 ANSWERS


  1. well marquee code is  "" < marquee >  TEXT  </ marquee> "" but together


  2. This may be a little crude, it's kind of off the top of my head ... I tested it quickly and it seems to work OK.  I over-used some variables to make it a little more clear what the code is trying to accomplish.  This should at least get you started ... you can customize it as necessary.

    Good luck!

    1. Place a label on your form name lblMarquee ... set the Text Align property to Right ... place some default text in the caption property like "caption"

    2. Set the font properties to what ever you need ... I've assumed a marquee text length to 20 characters ... depending on your need you can easily change this

    3. Open the code module for the form, and copy and paste the code below (double-check the padding string ... it needs 22 space characters ... Yahoo answers tends to truncate unnecessary stuff):

    Dim strInputText As String

    Dim strPadding As String

    Dim strScrollText As String

    Dim intTextLength As Integer

    Dim intPadLength As Integer

    Dim intPosition As Integer

    Dim intViewable As Integer

    Dim intRemaining As Integer

    Private Sub Form_Load()

    ' blank initial text from label

    lblMarquee.Caption = ""

    ' user defined input text

    strInputText = "This is to demonstrate a scrolling marquee with text moving from left to right."

    ' use enough padding to push text off marquee

    ' 22 space characters

    strPadding = "                      "

    ' concatenate input and padding

    strScrollText = strInputText & strPadding

    ' get length of marquee text

    intTextLength = Len(strScrollText)

    ' get length of padded text -

    ' to use later to reset marquee

    intPadLength = Len(strPadding)

    ' initialize vars

    ' time interval 1/2 second

    Me.TimerInterval = 500

    intPosition = 1

    intViewable = 1

    End Sub

    Private Sub Form_Timer()

    ScrollText

    End Sub

    Private Sub ScrollText()

    lblMarquee.Caption = Mid(strScrollText, intPosition, intViewable)

    intRemaining = intTextLength - (intPosition + intViewable - 1)

    If (intPosition - 1) < (intTextLength - intPadLength) Then

        ' adjust visible text length

        If intViewable < 20 And intViewable < intRemaining Then

            intViewable = intViewable + 1

        End If

        ' adjust text starting position

        If intPosition < intTextLength And intViewable >= 20 Then

            intPosition = intPosition + 1

        End If

    Else

        ' reset the whole thing

        lblMarquee.Caption = ""

        intPosition = 1

        intViewable = 1

    End If

    End Sub

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.