Mongooseman
New member
- Local time
- Today, 07:02
- Joined
- Jun 25, 2009
- Messages
- 4
I have a list box on a form, and I want to change the list box's Rowsource property every time the current record changes. I created a sub called populate() that builds a SQL statement and assigns it to the Rowsource property. The SQL looks like this:
SELECT RDM_No, part FROM RDM_Numbers WHERE part = [variable]
[variable] is the name field from the Form's Record Source (the Parts table). Populate() originally obtained [variable] from a text box whose Control Source property was tblParts.name, but although this method worked beautifully for simple viewing, it caused problems when editing (the text box value may not match the actual field value if the text box is still dirty). I then changed populate() to get [variable] from Me.Recordset.Fields("name").Value. This worked fine for editing, but it caused a strange problem.
Populate() is assigned to the Form's Load and Current events. It also runs when a change is made to the RDM_Numbers table via a Command Button. It works fine except when called from the Current event. [variable] is assigned before the record changes, the list box's values do not match the Form's current record. It did not have this problem when populate() pulled [variable] from the text box instead.
Any idea how I can fix this?
SELECT RDM_No, part FROM RDM_Numbers WHERE part = [variable]
[variable] is the name field from the Form's Record Source (the Parts table). Populate() originally obtained [variable] from a text box whose Control Source property was tblParts.name, but although this method worked beautifully for simple viewing, it caused problems when editing (the text box value may not match the actual field value if the text box is still dirty). I then changed populate() to get [variable] from Me.Recordset.Fields("name").Value. This worked fine for editing, but it caused a strange problem.
Populate() is assigned to the Form's Load and Current events. It also runs when a change is made to the RDM_Numbers table via a Command Button. It works fine except when called from the Current event. [variable] is assigned before the record changes, the list box's values do not match the Form's current record. It did not have this problem when populate() pulled [variable] from the text box instead.
Any idea how I can fix this?