A
Abes
I have this problem which I am unable to resolve, even from reading items in
this newsgroup. I am sure it is something I have missed but I cannot find it.
I have a main form (frmScheduleTippers) which contains a subform called
(sfrmScheduleTips). A combo box (cboRound) on the main form provides a value
which is passed to a query (qryCompetition2), along with other values that
are constant (such as Names and Competition), via VBA code. (The values for
firstname,LastName and Competition are passed by another form.)
My problem is that I cannot 'force' a refresh/requery of the subform data
(to reflect the data passed to the query) no matter what I try, unless I
close and reopen the entire form.
I have checked and the values of the SQL string (and therefore
qryCompetition2) are correct, as I change the combo box.
The code i am using is as follows:
Private Sub cboRound_AfterUpdate()
'To set the variables for the Query
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim strCompetition As String
Dim txtRoundNo As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryCompetition2")
'Get data for the query, from the Competition form
strSQL = "SELECT tblTips.* " & _
"FROM tblTips " & _
"WHERE tblTips.LastName='" & Me.txtTipperLastName.Value & "'" & _
"AND tblTips.FirstName='" & Me.txtTipperFirstName.Value & "'" & _
"AND tblTips.Competition='" & Me.txtipperCompetition.Value & "'" & _
"AND tblTips.RoundNo='" & Me.cboRound.Value & "'" & _
"ORDER BY tblTips.GameNo;"
qdf.SQL = strSQL
' This code to refresh the subform,dependant on the Round
' selected on main form
Me.sfrmScheduleTips.Visible = True
' Me.sfrmScheduleTips.SetFocus
Me.sfrmScheduleTips.Requery
' DoCmd.Requery "sfrmScheduleTips"
' Forms!frmScheduleTippers.Form!sfrmScheduleTips!txtRoundNo.SetFocus
' Forms!frmScheduleTippers.Form!sfrmScheduleTips!txtRoundNo.Requery
' txtRoundNo = Me.sfrmScheduleTips!txtRoundNo
' Forms!frmScheduleTippers!sfrmScheduleTips!txtRoundNo.SetFocus
' Forms!frmScheduleTippers!sfrmScheduleTips.Requery
DoCmd.RunCommand acCmdRefreshPage
Debug.Print strSQL
' Debug.Print txtRoundNo
Set qdf = Nothing
Set db = Nothing
End Sub
The commented actions are ones that I have attempted but to no result.
Any assistance to point out my error is greatly appreciated
this newsgroup. I am sure it is something I have missed but I cannot find it.
I have a main form (frmScheduleTippers) which contains a subform called
(sfrmScheduleTips). A combo box (cboRound) on the main form provides a value
which is passed to a query (qryCompetition2), along with other values that
are constant (such as Names and Competition), via VBA code. (The values for
firstname,LastName and Competition are passed by another form.)
My problem is that I cannot 'force' a refresh/requery of the subform data
(to reflect the data passed to the query) no matter what I try, unless I
close and reopen the entire form.
I have checked and the values of the SQL string (and therefore
qryCompetition2) are correct, as I change the combo box.
The code i am using is as follows:
Private Sub cboRound_AfterUpdate()
'To set the variables for the Query
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim strCompetition As String
Dim txtRoundNo As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryCompetition2")
'Get data for the query, from the Competition form
strSQL = "SELECT tblTips.* " & _
"FROM tblTips " & _
"WHERE tblTips.LastName='" & Me.txtTipperLastName.Value & "'" & _
"AND tblTips.FirstName='" & Me.txtTipperFirstName.Value & "'" & _
"AND tblTips.Competition='" & Me.txtipperCompetition.Value & "'" & _
"AND tblTips.RoundNo='" & Me.cboRound.Value & "'" & _
"ORDER BY tblTips.GameNo;"
qdf.SQL = strSQL
' This code to refresh the subform,dependant on the Round
' selected on main form
Me.sfrmScheduleTips.Visible = True
' Me.sfrmScheduleTips.SetFocus
Me.sfrmScheduleTips.Requery
' DoCmd.Requery "sfrmScheduleTips"
' Forms!frmScheduleTippers.Form!sfrmScheduleTips!txtRoundNo.SetFocus
' Forms!frmScheduleTippers.Form!sfrmScheduleTips!txtRoundNo.Requery
' txtRoundNo = Me.sfrmScheduleTips!txtRoundNo
' Forms!frmScheduleTippers!sfrmScheduleTips!txtRoundNo.SetFocus
' Forms!frmScheduleTippers!sfrmScheduleTips.Requery
DoCmd.RunCommand acCmdRefreshPage
Debug.Print strSQL
' Debug.Print txtRoundNo
Set qdf = Nothing
Set db = Nothing
End Sub
The commented actions are ones that I have attempted but to no result.
Any assistance to point out my error is greatly appreciated