randomly displaing a splashscreen and

G

GregB

I want access to randomly pick from multiple splash screens on the start up

Also I want to display random quotes in my access database.
How would one go about this?
 
F

Fred Boer

Dear GregB:

I've used a table of quotes {tblQuotes: QuoteID (Autonumber), Quote (Text)},
and the following code in the Open event of a form to populate a textbox
with a quote randomly selected from the table:

From form's Open event:

Dim lngQuoteCount As Long
lngQuoteCount = DCount("*", "tblQuotes")
Randomize
Me.txtQuote = DLookup("Quote", "tblQuotes", "[QuoteID]=" & _
Int((lngQuoteCount * Rnd) + 1))

I don't know how you would manage a randomly selected splash screen,
though...

Cheers!
Fred Boer
 
S

storrboy

Dear GregB:

I've used a table of quotes {tblQuotes: QuoteID (Autonumber), Quote (Text)},
and the following code in the Open event of a form to populate a textbox
with a quote randomly selected from the table:

From form's Open event:

Dim lngQuoteCount As Long
lngQuoteCount = DCount("*", "tblQuotes")
Randomize
Me.txtQuote = DLookup("Quote", "tblQuotes", "[QuoteID]=" & _
Int((lngQuoteCount * Rnd) + 1))

I don't know how you would manage a randomly selected splash screen,
though...


I would use the same idea, but using form names instead of quotes.
Either place form names in a table with a unique number, or keep them
in an array in the code. If you use the array, apply the same
randomizing as above, but reference the index number of the array.

Simple Example:

Dim aryForms([maxNumber]) As String
Dim a As Integer
aryForms(0) = FormName1
aryForms(1) = FormName2
aryForms(2) = FormName3

Randomize
a=Int((maxNumber- lowerboundOfAray + 1) * Rnd + lowerboundOfAray)

DoCmd.OpenForm aryForms(a)
 
Top