473,395 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Displaying a random tip of the day

Hi,

Can anybody advise on how i can get a random tip/joke of the day to display on a specific form within my d/base? I'd like to to scroll around for as long as the form is open and display a new tip/joke everyday.

Thanks
Oct 19 '07 #1
3 2498
Rabbit
12,516 Expert Mod 8TB
Part of it will depend on how you want to display it but the crux of the solution is to have a sequential Tip ID where you can randomly pick a number using the Randomize and Rnd function. Then it's a simple matter of looking up that ID.
Oct 19 '07 #2
ADezii
8,834 Expert 8TB
Hi,

Can anybody advise on how i can get a random tip/joke of the day to display on a specific form within my d/base? I'd like to to scroll around for as long as the form is open and display a new tip/joke everyday.

Thanks
Create a Table named tblTips. This Table will contain only 2 Fields, Field Number 1 will be TipID [INTEGER]. Make TipID the Primary Key but do not make it an AutoNumber. The entries in this Field should start at 1 and should be sequential in nature as in: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, etc.). Field Number 2 will be Tip (STRING) and will contain the actual Tip itself. Place this code wherever appropriate, to generate a Random Tip. The code is self-maintaining as long as you keep the TipIDs sequential. Good luck and let me know how you make out.
Expand|Select|Wrap|Line Numbers
  1. Dim intNoOfTips As Integer
  2. Dim intLowerbound As Integer, intUpperbound As Integer
  3. Dim intRandomTipNo As Integer
  4. Dim strRandomTip As String
  5.  
  6. Randomize
  7.  
  8. intNoOfTips = DCount("*", "tblTips")
  9.  
  10. intLowerbound = 1
  11. intUpperbound = intNoOfTips
  12.  
  13. intRandomTipNo = Int((intUpperbound - intLowerbound + 1) * Rnd + intLowerbound)
  14.  
  15. 'The Tip itself
  16. strRandomTip = DLookup("[Tip]", "[tblTips]", "[TipID]=" & intRandomTipNo)
  17. MsgBox strRandomTip
Oct 19 '07 #3
nico5038
3,080 Expert 2GB
At:
http://bostonaccessday.com/ugdownlds.cfm
you can find a sample database.

There's however a more versatile way, the so-called "web services". This will get a TipOfTheDay from the internet. Read more from:
http://www.databasejournal.com/featu...le.php/3567511

Nic;o)
Oct 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: Paul Rubin | last post by:
http://www.nightsong.com/phr/python/sharandom.c This is intended to be less predicable/have fewer correlations than the default Mersenne Twister or Wichmann-Hill generators. Comments are...
1
by: technoplonker | last post by:
I have an access 2000 database and I would like to create a script that will allow me to display 5 Random unique results. I have tried to use the tutorial at...
10
by: Virus | last post by:
Ok well what I am trying to do is have 1.) the background color to change randomly with 5 different colors.(change on page load) 2,) 10 different quotes randomly fadeing in and out in random...
1
by: robbiehenry | last post by:
There is this javascript reference site that I often use and I was looking for some script that would randomly show one of three images on page refresh. Here is the reference site that I use:...
6
by: Mike Langworthy | last post by:
i can not seem to get this code to work. someone please help using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program {
3
by: Blasting Cap | last post by:
On a web page (the default page of my app), I want to grab some shots off another of our websites (pictures of products that are already thumbnailed) for display on my page. I've found some...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
0
by: Steve | last post by:
The approach in this thread looks wrong to me considering your example. Your example shows you have random time periods between 6AM and 6 PM for appointments. Appointment 1 is 1-1/2 hour,...
0
by: readnlearn | last post by:
hai, i have written this below code for displaying captcha image whenever i entered incorrect uname,password in login page. for that i disable the controls of captcha like textbox,labels,button and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.