Results 1 to 11 of 11
  1. #1
    GaryElwood is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    12

    Display multiple scrolling messages

    Problem: I want to be able to scroll multiple messages across the top of a form. I have a table (tbl_Messages) with a field called (Message). The table has multiple records. I want to start with the first record, scroll it across the screen and then move to the next message, scroll and continue through all messages in the table. I can get the first message to work but can’t move to the next record?


    My message starts at (message.left=700) and should end and load the next message when (message.left>14400)
    TimerInterval=45
    Thanks for your assistance,
    Gary

  2. #2
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    You didn't describe what, exactly, it is doing, and you didn't post the code that you used to try to reload the message.

    My guess is that you maybe didn't set up the query on the message to wait around, open, until your timer ran out, then read the next one. So it may be reading and loading the same message over and over again.

    I'm going to assume you're using a label called lblScroll and are changing its .Left property every time your timer ticks.

    Here's how I'd set it up so that you don't have to keep a query recordset sitting around for no good reason.

    1) Create a hidden listbox lstMsg.
    Set lstMsg.Visible = No and .Enabled = no.
    Set lstMsg.[Row Source] = "Select [Message] from [tbl_Messages]"
    (This assumes that you want all the Message records, in any order. If not, then you should add whatever limits and ORDER BY you want on the messages)

    2) Create a hidden text box txtMsgno.
    Set txtMsgNo.Visible = No and txtMsgNo.Enabled = no.
    Set txtMsgNo.[Default Value] = 0

    3) Whenever your timer says to change the message,
    Code:
       ' calculate next message number
       txtMsgNo = txtMsgNo + 1
       if txtMsgNo > lstMsg.   then
          txtMsgNo = 0
       end if 
     
       ' set next message caption
       lblScroll.Caption = lstMsg.Control(txtMsgNo)   
    
       'set label back to the middle
       lblScroll.Left = 700

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I haven't tried or even thought about doing this, but off hand, I can think of two methods that might work.

    Possible solutions:
    1) Since the messages are stored in a table, open a recordset on that table. Loop through the records, concatenating in a string variable. Then display as you are doing now. You could use leader dots (......) to separate the messages.

    2) You have to be able to read the message from the table, soooo, use a recordset instead of the table. Loop through the recordset, pausing until message.left>14400.

    I know this is very general, but I don't know what code you are using..

  4. #4
    GaryElwood is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    12
    Dal....
    Thanks for your assistance.... But i'm still having a problem. I'm getting a "Type mismatch" error on "MessageBoard.Caption = lstMsg(txtMsgno)"

    'Me.MessageBoard.Caption = lstMsg(txtMsgno)
    If (MessageBoard.Left < 14400) Then
    MessageBoard.Left = MessageBoard.Left + 40
    Else
    ' calculate next message number
    txtMsgno = txtMsgno + 1
    If (Me.txtMsgno > lstMsg) Then
    txtMsgno = 0
    End If

    ' set next message caption
    MessageBoard.Caption = lstMsg(txtMsgno)

    'set label back to the middle
    MessageBoard.Left = 700
    End If

  5. #5
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    1) how many columns did you load the listbox with?

    for one column, use

    MessageBoard.Caption = lstMsg.Control(txtMsgno)

    for two columns, to get the second one use

    MessageBoard.Caption = lstMsg.Control(txtMsgno,1)


    2) I forgot to research the name of the listbox's count variable. I had left a period after listMsg. to remind myself to look it up. Change the test to ...

    If (Me.txtMsgno > lstMsg.ListCount ) Then

  6. #6
    GaryElwood is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    12
    I really appreciate all your help...but.... I still can not get it to work.
    I have the following code in the on Timer event:

    (I don't understand the "MessageBoard.Caption = lstMsg.Control(txtMsgno)" What is the .Control doing?)
    I still get type mismatch when i run this...


    Me.MessageBoard.Caption = lstMsg(txtMsgno)
    If (MessageBoard.Left < 14400) Then
    MessageBoard.Left = MessageBoard.Left + 40
    Else
    ' calculate next message number
    txtMsgno = txtMsgno + 1
    If (Me.txtMsgno > lstMsg.ListCount) Then
    txtMsgno = 0
    End If
    ' set next message caption
    MessageBoard.Caption = lstMsg(txtMsgno)
    'set label back to starting point
    MessageBoard.Left = 700
    End If

  7. #7
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Sorry, not "Control", but "Column". My hands typed the wrong "Co" word.

  8. #8
    GaryElwood is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    12
    Still can not get this to work....
    I don't understand:
    ' set next message caption
    MessageBoard.Caption = lstMsg(txtMsgno)

    How does changing the column number move to the next record?

  9. #9
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Man, on this thread I ought to change my title to "incompetent performer". I really need to slow down my typing and doublecheck everything after I make my first mistake.

    http://msdn.microsoft.com/en-us/libr...ffice.14).aspx

    Column is a two-dimension property, the first dimension is column, and the second dimension is row. You want the first column (your message) for each row.

    So, try this:

    MessageBoard.Caption = lstMsg.Column(0,txtMsgno)

  10. #10
    GaryElwood is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    12
    Thanks Dal for all the help!
    It now works!!!!

  11. #11
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Awesome! Please mark thread "solved". Top of page, under Thread Tools.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Macro messages
    By GraemeG in forum Programming
    Replies: 1
    Last Post: 06-03-2011, 07:57 AM
  2. Messages
    By grankioto in forum Forms
    Replies: 1
    Last Post: 11-18-2010, 09:26 PM
  3. Custom messages to Access' default error messages.
    By evander in forum Programming
    Replies: 1
    Last Post: 06-26-2010, 02:06 AM
  4. Replies: 0
    Last Post: 04-13-2009, 04:02 AM
  5. Error Messages
    By DataGeek in forum Access
    Replies: 0
    Last Post: 12-06-2007, 09:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums