Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Random txtbx (2002 SP-3)

    Ok, now I'm just getting crazy.
    Anyone know of a way to have a "random" txtbx/memo appear in the header of a form each time it's opened?
    By this I mean to say a different display each time.
    <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15> appreciated.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Random txtbx (2002 SP-3)

    Are you talking about something in the line of a "tips" display? Do you have a table with each display text block in a separate record?
    Charlotte

  3. #3
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Random txtbx (2002 SP-3)

    Hey Charlotte, long time no "talk" to. Yeah, like "tips".
    I haven't done anything yet, just looking into how difficult it would be.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Random txtbx (2002 SP-3)

    The best way to do this is to create a table (as mentioned by Charlotte) with a text or memo field. Each "tip" would be in its own record. When you open the form, open a recordset on the table, do a recordcount, then pick a random number n between 1 and the number of records and retrieve the n-th record. Display the text field in a message box, or as caption of a label.

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Random txtbx (2002 SP-3)

    I attach a little demo of how you could do it.

    It would be more complicated to try to remember what had happened in the past to ensure that a different tip was shown each time, but it could be done.

    This uses the random function rnd to choose a tip.
    Regards
    John



  6. #6
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Random txtbx (2002 SP-3)

    <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15> <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  7. #7
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Random txtbx (2002 SP-3)

    Thanks John, I'll look it over.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  8. #8
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Random txtbx (2002 SP-3)

    John,

    I see what you mean; it shows the same "tip" two or three times in a row before changing. Nice little trick though, so I've incorporated it into the app anyway. Maybe Hans will jump in later with some of his modification "tricks"; the guy just scares me sometimes! <img src=/S/yikes.gif border=0 alt=yikes width=15 height=15>
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  9. #9
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Random txtbx (2002 SP-3)

    Hans,

    The attached code (courtesy of John) seems to work "OK", but it doesn't change every time. It is in the On Load Event.
    Got any tricks up your sleeve?
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  10. #10
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Random txtbx (2002 SP-3)

    It generate a random number within the range of 1 to numberoftips. If the number of tips is small, there is a high chance that successive numbers might be the same .

    As the number of tips increases the probability of this happening will get smaller.

    You could record somewhere perhaps in a separate table, the last number generated. Then each time check the new number against that. If they match generate another one. Depends whether it actually matters or not.
    Regards
    John



  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Random txtbx (2002 SP-3)

    As John remarks, if the number of "tips" is small, the probability of repetitions is high. You could store the last ID displayed, and draw randum numbers until you get a different one, but it would still be possible to get tip #2, then tip #5, then tip #2, then tip #5 again. So you ask "can't we avoid repeating the last two tips?" If you extend this, you'd lose all randomness. It's better to ensure that you have a large collection of tips. If you don't, ask yourself it it's worth the trouble to display them.

  12. #12
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Random txtbx (2002 SP-3)

    John,

    Oh, well that may make all the difference in the world then - I only have three records in the set right now. I'll probably end up with twenty or so in the end; think that will be enough to make a difference? Thanks for the code BTW, I just LOVE <img src=/S/free.gif border=0 alt=free width=30 height=15> stuff (especially when it works) <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  13. #13
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Random txtbx (2002 SP-3)

    Here is another attachment that remembersthe last tip, but as Hans comments it can still go tipone, tipfive, tipone etc.

    If you have multiple users, you might want to be sure that each user gets a different tip from last time.
    Regards
    John



  14. #14
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Random txtbx (2002 SP-3)

    Thanks Hans; as I mentioned to John, I will probably have twenty or so in the end. I'll give that a go and see how much it improves. As always, I very much appreciate the feed-back!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  15. #15
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Random txtbx (2002 SP-3)

    <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>
    Thanks for all the help John!
    Data entry time!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •