UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Music Quiz, Access 2003    
 
   
robUK
post Oct 10 2019, 10:45 AM
Post#1



Posts: 391
Joined: 20-January 04



I am compiling a list of questions and answers, for a music quiz, which I want to put into a simple database. The table will be quite simple. Question, Answer, and Category, Date Last Used, True/False. I also intend to have a check box on the form, for selecting records, which will then be used in a query, to print out a question sheet (report).
What I need it to do, and this is where I need help, is when the checkbox is ticked, the Date Last Used, is completed with the current date. This is where it's a little more complicated, for me anyway. When I want a new question sheet, I want to be able to clear all the tick boxes, but the dates to remain. This is so I don't select the question again, in a short period of time. If selected again though, will be updated with the new current date. Hope all this makes sense.
Go to the top of the page
 
theDBguy
post Oct 10 2019, 10:49 AM
Post#2


Access Wiki and Forums Moderator
Posts: 76,379
Joined: 19-June 07
From: SunnySandyEggo


Hi. Depending on your preference, you can try this two different ways. The first one is to use VBA and in the AfterUpdate of the checkbox, update the date selected. Or, the second one is to use an UPDATE query to update the date selected field for all checked boxes, all in one go. You can also use an UPDATE query to clear all checkboxes at once.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
arnelgp
post Oct 10 2019, 10:51 AM
Post#3



Posts: 1,424
Joined: 2-April 09
From: somewhere out there...


add the [Date Last Used] to your form.
and on the Click Event of the checkbox, set the field above to Now().
CODE
private sub chk_click()
if me.chk then me![date last used]=now()
end if


add a button that will clear all check marks,
add code to its click event:
CODE
private sub clrButton_Click()
dim ctl as ctl
for each ctl in me.controls
    if typeof ctl is checkbox then
        ctl.value=false
    end if
next
end sub


--------------------
Never stop learning, because life never stops teaching.
Go to the top of the page
 
ADezii
post Oct 10 2019, 11:54 AM
Post#4



Posts: 2,675
Joined: 4-February 07
From: USA, Florida, Delray Beach


I created a similar type Database many years ago but only related to Hazardous Materials. This DB allowed a User to enter a Random Number of Questions up to 100. X number of Random Questions would then be generated in the form of a Report which was then printed generating a written Test. Once the Random Test (Report) was closed, the User was then given an option to Print out an Answer Sheet for those questions. The Test and Answer Sheets are generated by pro-grammatically selecting/deselecting a Check Box (Yes/No Field) in a Table which is where the similarity to your Project comes in. I'll Upload it to you and hopefully you may find it useful in your case. Keep in mind that this was developed many, many years ago when I was just beginning my programming career. laugh.gif
Attached File(s)
Attached File  Random_Test_Questions.zip ( 38.49K )Number of downloads: 2
 
Go to the top of the page
 
robUK
post Oct 10 2019, 11:55 AM
Post#5



Posts: 391
Joined: 20-January 04



Thank you both, for your suggestions. Arnelgp, should that be 'end sub' in your first piece of code, for selecting the date. I've changed it to end sub, and it works.
With the clrButton, I'm getting Compile error: User defined type not defined, at dim ctl as ctl.
EDIT: Ignore me, brain freeze. I forgot to put the control name in. No, still not working.

CODE
Private Sub clrButton_Click()
Dim ctl As ctl
For Each ctl In Me.Select_Question
    If TypeOf ctl Is CheckBox Then
        ctl.Value = False
    End If
Next
End Sub

This post has been edited by robUK: Oct 10 2019, 12:10 PM
Go to the top of the page
 
robUK
post Oct 10 2019, 12:02 PM
Post#6



Posts: 391
Joined: 20-January 04



Thank you ADezii. This might also be useful for creating the quiz sheets.
This post has been edited by robUK: Oct 10 2019, 12:03 PM
Go to the top of the page
 
ADezii
post Oct 10 2019, 12:26 PM
Post#7



Posts: 2,675
Joined: 4-February 07
From: USA, Florida, Delray Beach


yw.gif
Go to the top of the page
 
isladogs
post Oct 10 2019, 01:02 PM
Post#8


UtterAccess VIP
Posts: 1,680
Joined: 4-June 18
From: Somerset, UK


In arnelgp's code replace the Dim line with
Dim ctl As Access.Control or just Dim ctl As Control

The following line in your code needs to be changed back to that given by arnelgp : For Each ctl in Me.Controls

--------------------
Go to the top of the page
 
robUK
post Oct 10 2019, 01:44 PM
Post#9



Posts: 391
Joined: 20-January 04



QUOTE
In arnelgp's code replace the Dim line with
Dim ctl As Access.Control or just Dim ctl As Control

The following line in your code needs to be changed back to that given by arnelgp : For Each ctl in Me.Controls


Done all that. It only deletes the control for the record I'm in.
Go to the top of the page
 
isladogs
post Oct 10 2019, 02:17 PM
Post#10


UtterAccess VIP
Posts: 1,680
Joined: 4-June 18
From: Somerset, UK


Suggest you upload a stripped down copy of your database

--------------------
Go to the top of the page
 
robUK
post Oct 10 2019, 02:30 PM
Post#11



Posts: 391
Joined: 20-January 04



Attached File  Music_Quiz.zip ( 24.14K )Number of downloads: 3
Here it is.
Go to the top of the page
 
tina t
post Oct 10 2019, 02:38 PM
Post#12



Posts: 6,107
Joined: 11-November 10
From: SoCal, USA


QUOTE
When I want a new question sheet, I want to be able to clear all the tick boxes, but the dates to remain. This is so I don't select the question again, in a short period of time. If selected again though, will be updated with the new current date.

hello, rob, re the above quote. when you get to that point in your programming:

unless it's important to know the time of day that a checkbox was ticked, suggest you populate your date/time field using Date(), rather than using Now(). just easier to not deal with varied time values unless they're necessary to the process. :)

hth
tina
This post has been edited by tina t: Oct 10 2019, 02:38 PM

--------------------
"the wheel never stops turning"
Go to the top of the page
 
isladogs
post Oct 10 2019, 02:42 PM
Post#13


UtterAccess VIP
Posts: 1,680
Joined: 4-June 18
From: Somerset, UK


OK if you want the Boolean field to be set false for all records, use an update query
CODE
UPDATE [tblMusic Questions] SET [tblMusic Questions].[Select Question] = False;


Also as you only have one Boolean field per record then you can simplify your button code to clear the selection for that record to

CODE
Private Sub clrButton_Click()
Me.Select_Question = False
End Sub

--------------------
Go to the top of the page
 
robUK
post Oct 10 2019, 02:49 PM
Post#14



Posts: 391
Joined: 20-January 04



Thanks Tina t, for your advice, and isladogs for the code. I'll make the amendments, and try it out.
Go to the top of the page
 
robUK
post Oct 10 2019, 03:00 PM
Post#15



Posts: 391
Joined: 20-January 04



Thank you guys for all your assistance. It's working exactly how I want it to at the moment. Now to work on the quiz sheet reports. Thanks again.
Go to the top of the page
 
isladogs
post Oct 11 2019, 01:39 AM
Post#16


UtterAccess VIP
Posts: 1,680
Joined: 4-June 18
From: Somerset, UK


Excellent. Good luck with your project.

--------------------
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    15th October 2019 - 03:46 AM