R
Ripper
I am designing this dBase for some Special Ed students. They need much more repetition to help remember things so this dBase will help them achieve that
I have a form, frmDayOfWeek, that has two fields on it, Today and DayAfter. I want a random day of the week to appear in the field Today, stored so I can use it on the report, and then the students will type in whatever the next day of the week is in the field DayAfter
I have a table, tblDaysOfWeek, that has and ID field and a Day field. The ID range from 1 to 7 and the correspont with the day of the week. 1=Sunday, 2=Monday, 3=Wednesday, etc
I thought the code would generate a random number, go get the day of the week from the tblDaysOfWeek, and put that day in the field Today on the current form
With this code, am I in the right ballpark or is there a better way to do what I want
'Highest form numbe
Const lngcUpperBound =
'Lowest form numbe
Const lngcLowerBound =
Dim lngFormNumber As Lon
Dim strRandomDay As Strin
'Requires reference to Microsoft DAO 3.6 Object Library (or 3.51 for Access 97)
Dim db As DAO.Databas
Dim rst As DAO.Recordse
'Generate a random number in the specified range. See 'Rnd Function' in the help file for details
Randomize Time
lngFormNumber = Int((lngcUpperBound - lngcLowerBound + 1) * Rnd + lngcLowerBound
'Open a recordset to get the form name corresponding to the randomnumber
Set db = CurrentD
Set rst = db.OpenRecordset("SELECT [Day] FROM tblDaysofWeek WHERE [Day] = Weekday(" & lngFormNumber & ")"
---> HOW DO I GET THE RANDOM DAY INTO THE TODAY FIELD ON THE FORM
Thanks
RI
I have a form, frmDayOfWeek, that has two fields on it, Today and DayAfter. I want a random day of the week to appear in the field Today, stored so I can use it on the report, and then the students will type in whatever the next day of the week is in the field DayAfter
I have a table, tblDaysOfWeek, that has and ID field and a Day field. The ID range from 1 to 7 and the correspont with the day of the week. 1=Sunday, 2=Monday, 3=Wednesday, etc
I thought the code would generate a random number, go get the day of the week from the tblDaysOfWeek, and put that day in the field Today on the current form
With this code, am I in the right ballpark or is there a better way to do what I want
'Highest form numbe
Const lngcUpperBound =
'Lowest form numbe
Const lngcLowerBound =
Dim lngFormNumber As Lon
Dim strRandomDay As Strin
'Requires reference to Microsoft DAO 3.6 Object Library (or 3.51 for Access 97)
Dim db As DAO.Databas
Dim rst As DAO.Recordse
'Generate a random number in the specified range. See 'Rnd Function' in the help file for details
Randomize Time
lngFormNumber = Int((lngcUpperBound - lngcLowerBound + 1) * Rnd + lngcLowerBound
'Open a recordset to get the form name corresponding to the randomnumber
Set db = CurrentD
Set rst = db.OpenRecordset("SELECT [Day] FROM tblDaysofWeek WHERE [Day] = Weekday(" & lngFormNumber & ")"
---> HOW DO I GET THE RANDOM DAY INTO THE TODAY FIELD ON THE FORM
Thanks
RI