Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Item_CustomPropertyChange in OUtlook

Status
Not open for further replies.

JustNigel

Programmer
Dec 9, 2002
7
EU
The Item_CustomPropertyChangeevent does not always seem to fire, triggering the Item_CustomPropertyChange procedure

I have a custom form that, amongst other fields, has two combo boxes on it.

The first combo box is populated from a table within an Access 97 database. The code for which resides within the Item_CustomPropertyChange(Value) procedure. This code, based on a SQL string, works fine.

The second combo box is also populated from an Access 97 table, but the values extracted from the table depend on the value entered in the first combo box.

My problem is that the second combo box is only populated after a value is entered in the first combo box AND another field on the form is populated. Obviously I'm wanting the second combo to be populated after the first without any other fields being maipulated.

Any help would be greatly appreciated, my code is shown below.

Item_CustomPropertyChange(Value)

'Code here defining database, recordset and pathway....

strSql = "SELECT UnitFullName FROM tblUnit"
set rst =db.openrecordset (strsql)
rst.movefirst
do until rst.eof
strUnitComboList = strUnitComboList & rst.UnitFullName & ";"
rst.movenext
loop
ctls("Subject").PossibleValues=strUnitComboList

'The code above populates the first combo box.

If ctls("Subject").Value = "" Then
'Do nothing - No value in first combo box
Else
strCostCentreSQL = "SELECT CostCentre FROM tblUnit WHERE UnitFullName = " & "'" & ctls("Subject").Value & "'"
set rs1 = db.OpenRecordset (strCostCentreSQL)
rs1.MoveFirst
strCostCentre = rs1.CostCentre

strTeamUnitSQL = "SELECT TeamID_TeamUnit FROM tblTeamUnit WHERE CostCentre_TeamUnit = " & strCostCentre
set rs2 = db.OpenRecordset (strTeamUnitSQL)
rs2.MoveFirst
do until rs2.eof
strTeamIDSQL = "SELECT TeamFullName FROM tblTeam WHERE TeamID = " & rs2.TeamID_TeamUnit
set rsTeams = db.OpenRecordset (strTeamIDSQL)
rsTeams.MoveFirst
strTeamIDList = strTeamIDList & rsTeams.TeamFullName & ";"
rs2.MoveNext
Loop
ctls("cmbTeam").PossibleValues = strTeamIDList
End If

'Other code here

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top