D
Dave
I have a combobox on a subform that is displayed as continuous forms in the
parent form.
When a user makes a selection in the combobox, the afterupdate event fires
and executes a SQL query using ADO objects. The SQL query using the ID from
the combo box selection as part of its WHERE clause.
I am having a problem with event timing.
When the SQL code executes, the ID specified in the combobox has not been
written to the database yet. So no records are returned because the ID
specified in the WHERE clause does not yet exist in the database and my
query operates on an empty set.
If I add a Me.Requery to my code, the ID is written to the database and
everything works fine for the first record. However, the Requery reloads the
subform, making the first record the active record. So when I reference the
ID in the cbo, I am now referencing the ID of the first record, not the ID
of a subsequent record I was working with before the requery. My WHERE
clause nows operates on all the records that match the first record's ID,
not the ID of the record I was working with before the requery.
I can probably work around this by using a global variable or bookmark to
store the ID before I requery. However, this seems like a hack. Does anyone
know a cleaner way to approach this?
parent form.
When a user makes a selection in the combobox, the afterupdate event fires
and executes a SQL query using ADO objects. The SQL query using the ID from
the combo box selection as part of its WHERE clause.
I am having a problem with event timing.
When the SQL code executes, the ID specified in the combobox has not been
written to the database yet. So no records are returned because the ID
specified in the WHERE clause does not yet exist in the database and my
query operates on an empty set.
If I add a Me.Requery to my code, the ID is written to the database and
everything works fine for the first record. However, the Requery reloads the
subform, making the first record the active record. So when I reference the
ID in the cbo, I am now referencing the ID of the first record, not the ID
of a subsequent record I was working with before the requery. My WHERE
clause nows operates on all the records that match the first record's ID,
not the ID of the record I was working with before the requery.
I can probably work around this by using a global variable or bookmark to
store the ID before I requery. However, this seems like a hack. Does anyone
know a cleaner way to approach this?