murray83
Games Collector
- Local time
- Today, 18:18
- Joined
- Mar 31, 2017
- Messages
- 827
i have my quiz DB which is going fine and thanks to all who have helped along the way, but i think this will be my last question to do with it
have this sub which was written by people smarter than me, and its nicley commented which helps
But to the question, how would i go about altering this if i wanted the picture to appear in the command buttons, for example if i had question like so: see attached image rather then have the image appear in the top of the page ?
have this sub which was written by people smarter than me, and its nicley commented which helps
Code:
Private Sub GetQuestion()
Dim dbs As DAO.Database, rst As DAO.Recordset, x As Integer
Set dbs = CurrentDb
Me.QImage.Visible = False
Me.Question.Width = 6804 'Set the full width of the question box
'Me.GotoNextQuestion.Enabled = False
'Me.FiftyFifty.Enabled = True
'Get the question and choices from the tables according to the question round number and question number
Set rst = dbs.OpenRecordset("SELECT tblQuestions.QRoundNo, tblQuestions.QuestionNo, Question, ChoiseNo, Choise, RightAnswer, ImageAttached " _
& "FROM tblQuestions INNER JOIN tblQuestionChoice ON (tblQuestions.QuestionNo = tblQuestionChoice.QuestionNo) AND (tblQuestions.QRoundNo = tblQuestionChoice.QRoundNo) " _
& "WHERE tblQuestions.QRoundNo=" & TempVars!QRoundNo & " AND tblQuestions.QuestionNo=" & RememberQuestionNo & ";")
If Not rst.EOF Then 'Is some data found?
'Yes data found, then prepare the form
Me.Caption = "Question " & rst![QuestionNo] 'Set the form's caption
Me.QuestionNo.Caption = Me.Caption 'Set the QuestionNo (label) caption
Me.Question = rst![Question] 'Set the Question
If Not IsNull(rst![ImageAttached]) Then 'Some picture is attached to the question
Me.Question.Width = 4479 'Reduce the width of the question box so the picture box not covered some of the question
Me.QImage.Visible = True 'Show the picture box
Me.QImage.Picture = rst![ImageAttached] 'Put the picture in the picture box
End If
For x = 1 To 4 'Prepare the 4 choises button
Me("Choise" & x).Visible = True 'Make the button visible
Me("Choise" & x).Enabled = True 'Make the button enable
Me("Choise" & x).Caption = rst![Choise] 'Put the choise in the button's caption
Me("Choise" & x).Tag = rst![RightAnswer] 'Mark the button as right or wrong choise
rst.MoveNext
Next x
'Me.FiftyFifty.SetFocus 'Move the focus from the 4 choises to the FiftyFifty button
Else
Me.Visible = False
MsgBox ("Sorry, no more questions!") 'Question round is finish
DoCmd.OpenForm "F_Results"
Forms!F_Results.Refresh
Forms!F_Results!txtSecondsTaken.Value = txtYouHaveTaken.Value
End If
End Sub
But to the question, how would i go about altering this if i wanted the picture to appear in the command buttons, for example if i had question like so: see attached image rather then have the image appear in the top of the page ?