Populating a subform from a listbox

  • Thread starter MPWoodhams via AccessMonster.com
  • Start date
M

MPWoodhams via AccessMonster.com

Hi all,

Having spent the last couple of days banging my head against my monitor
trying to work this out - I thought I would turn it out to the gurus here.

I'm working with a form (FrmClientEnquiries) which will populate records in
TblClientEnquiries.
Based on the user's selection in a listbox of 'RequestType' (LboRequestType),
I need the subform (sFrmRespChecks) to populate a series of records based on
the various 'Resp' asociated with the 'RequestType'.

Tables include:

TblRequestTypes
RTID (PK; autonumber)
RequestType (eg: CID, Doc Check, Account Name Change,...)

TblResp
RID (PK; autonumber)
Resp (eg: Client, RM, RM Support,...)

TblRRLinks
RRID (PK; autonumber)
RequestType (Sourced from TblRequestType)
Resp (Sourced from TblResp)

TblClientEnquiries
CEID (PK; autonumber)
RMSTSubteam
Client
Administrator
RequestType
...

TblRespChecks
RCID (PK; autonumber)
CEID (sourced from FrmClientEnquiries)
Resp (Sourced from TblRRLinks)
Completed (Yes/No; Checkbox)

****************************************************

Code currently being used (I picked up & worked from John Vinson's "Animal
Clinic" sample which has been posted here a number of times):

Private Sub LboRequestType_AfterUpdate()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim StrSQL As String
Dim StrResp As String
Dim StrRequestType As String
Dim IntRTID As Integer
Dim IntRRID As Integer

If Me.NewRecord = True Or Me.RecordSource = "" Then
Exit Sub
End If

Me.CboRequestType.Requery
Me.sFrmRespChecks.Requery

Set db = CurrentDb

StrSQL = "SELECT RRID, Resp From TblRRLinks WHERE " & _
"RequestType = '" & Me.[CboRequestType] & "'"

Set rs = db.OpenRecordset(StrSQL, dbOpenDynaset)

With Me.CboRequestType
For IntRTID = 0 To .ListCount - 1
rs.FindFirst "[Resp] =" & .Column(1, IntRTID)
.Selected(IntRTID) = Not rs.NoMatch
Next IntRTID
End With

rs.Close
Set rs = Nothing
Set db = Nothing


End Sub

****************************************************************

Alright - so the code runs quite happily, but I'm not getting anything with
regards to having sFrmRespChecks being populated when the user selects a
RequestType from the listbox.

Any thoughts/guidance with this are greatly appreciated. I've been running
around in circles for the last couple of days trying to get this ticking over.


Many thanks to everyone.

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top