random message

deekras

Registered User.
Local time
Today, 12:55
Joined
Jun 14, 2000
Messages
169
i have a table that contains messages to be displayed if the user enters a correct answer([correct messages] and another table for messages if the user enters an incorrect answer (incorrect messages].

my question is: i want any one of the messages from [correct messages]to be displayed, at random. how do i include it in the msgbox?
 
this is what i figured out and it works. but is there a better way?

If [answer] <> [Forms]![game]![Form1]![correct answer] Then
Randomize (0)
message = DLookup("[message]", "[incorrect_messages]", "[code_number] = Int((4 * Rnd) + 1)")

MsgBox [message], 0, "Incorrect Answer"

Else
If [answer] = [Forms]![game]![Form1]![correct answer] Then
Randomize (0)
message = DLookup("[message]", "[correct_messages]", "[code_number] = Int((4 * Rnd) + 1)")
MsgBox [message], 0, "Correct Answer"
End if
End If

Also, how doi tell the system to count the number of messages so i could that number instead of the 4 that i have there now?
 

Users who are viewing this thread

Back
Top Bottom