aziz rasul
Active member
- Local time
- Today, 01:24
- Joined
- Jun 26, 2000
- Messages
- 1,935
On an unbound form, I have a list box and a subform whose record source is "qryContactinSlimwell". There are other controls on the main form. The list box has a list of names. The purpose of the subform is to give the details of the chosen name. Hence as each name is selected, the details in the subform should change accordingly.
When I select an item in the list box, the Click event of the list box is: -
Call CreateQuery("qryContactinSlimwell", strSQL) is a piece of code that creates the query based on strSQL.
The query is created successfully depending on the chosen name, but the details in the subform are not refreshing?
If I select a name, close the form and re-open it, then it works, but I don't want to do that as the other controls on the form are selected to certain values which I want to retain.
When I select an item in the list box, the Click event of the list box is: -
Code:
Private Sub lstUnassignedWaitingList_Click()
Dim strSQL As String
Dim ctl As Control
Dim x As Variant
Set ctl = Me.lstUnassignedWaitingList
Me.Refresh
Me.frmcontactdetails.Visible = True
Me.frmEnquirerSubformPrimary2.Visible = True
Me.lblcontactdetails.Visible = True
For Each x In ctl.ItemsSelected
strSQL = "SELECT tblEnquirers.enquirerID, tblEnquirers.GPID, tblEnquirers.NHSNumber, tblEnquirers.Surname, tblEnquirers.firstname, tblEnquirers.postcode, tblEnquirers.housenumber, tblEnquirers.streetname, tblEnquirers.Area, tblEnquirers.County, tblEnquirers.towncity, tblEnquirers.telno, tblEnquirers.emailaddress, tblEnquirers.DOB, tblEnquirers.nationalethnicitycode, tblEnquirers.Disability, tblEnquirers.disabilitydetails, tblEnquirers.Gender, tblEnquirers.Height, tblEnquirers.emergencycontactname, tblEnquirers.emergencycontacttelno, tblEnquirers.foodallergy, tblEnquirers.foodallergydetails, tblEnquirers.Comments " & _
"FROM tblEnquirers INNER JOIN tblGroupWaitingList ON tblEnquirers.enquirerID = tblGroupWaitingList.enquirerID " & _
"GROUP BY tblEnquirers.enquirerID, tblEnquirers.GPID, tblEnquirers.NHSNumber, tblEnquirers.Surname, tblEnquirers.firstname, tblEnquirers.postcode, tblEnquirers.housenumber, tblEnquirers.streetname, tblEnquirers.Area, tblEnquirers.County, tblEnquirers.towncity, tblEnquirers.telno, tblEnquirers.emailaddress, tblEnquirers.DOB, tblEnquirers.nationalethnicitycode, tblEnquirers.Disability, tblEnquirers.disabilitydetails, tblEnquirers.Gender, tblEnquirers.Height, tblEnquirers.emergencycontactname, tblEnquirers.emergencycontacttelno, tblEnquirers.foodallergy, tblEnquirers.foodallergydetails, tblEnquirers.Comments, tblGroupWaitingList.groupprojectID " & _
"HAVING (((tblEnquirers.enquirerID)=" & Int(ctl.ItemData(x)) & ") AND ((tblGroupWaitingList.groupprojectID)=1));"
Call CreateQuery("qryContactinSlimwell", strSQL)
Me.frmEnquirerSubformPrimary2.Requery
Me.Requery
Next x
End Sub
Call CreateQuery("qryContactinSlimwell", strSQL) is a piece of code that creates the query based on strSQL.
The query is created successfully depending on the chosen name, but the details in the subform are not refreshing?
If I select a name, close the form and re-open it, then it works, but I don't want to do that as the other controls on the form are selected to certain values which I want to retain.