In the first query, the value of combo2
is included in the WHERE
clause.
But the second query includes the combo's name instead of its value. In other words, this is the WHERE
clause built by the code ...
WHERE Contracts.cms = combo2
In that situation, I would expect Access to treat combo2
as a parameter and ask you to supply a value for it. But you didn't mention that, so something more may be going on.
The code includes ...
If Combo1 = "Staff Name" Then
... but there is no closing End If
later. Perhaps, you've shown us an abbreviated version of your actual code, and the actual version does include End If
?
Rather than sorting out those details, I'll suggest a different approach. Make a backup copy of your db file. Use this query as the RowSource
for List3
on subFormB
.
SELECT Staff.department
FROM Staff
WHERE Staff.staff_name = Forms!FormA!combo2;
Then, in Combo2_AfterUpdate
of FormA
, just Requery
the subform's listbox, or even the entire subform, instead of altering the listbox RowSource
... one of these two ...
Me!subFormB!List3.Requery
Me!subFormB.Requery
If that approach is satisfactory, apply the same strategy to the other subform . And if it fails completely, revert back to your backup db.