Execution flow

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

My mainframe mind seemingly doesn't know how
execution flow works in VBA. In the segment:

Case "Hornets"
DoCmd.OpenForm "HornetsNet"
Me.CmboFilters.Requery

I expect that execution control will be given tothe
form "HornetsNet" when "Hornets" is selected
in the combo box "CmboFilters", which it is. The
mystery is how come the Me.CmboFilters.Requery
doesn't cause the combo box to clear when the
"HornetsNet" form is closed and execution flow
continues on the Requery statement?

Bill
 
Not quite how it works. The code below does not halt when you issue the
DoCmd.OpenForm. The next line of code executes.
This is true except for dialog forms where the code does halt.
 
In other words, to achieve what you want, specify that you want to open the
form in Dialog mode:

DoCmd.OpenForm "HornetsNet", , , , , acDialog

or

DoCmd.OpenForm FormName := "HornetsNet", WindowMode := acDialog
 
Thanks Doug.
Bill


Douglas J. Steele said:
In other words, to achieve what you want, specify that you want to open
the form in Dialog mode:

DoCmd.OpenForm "HornetsNet", , , , , acDialog

or

DoCmd.OpenForm FormName := "HornetsNet", WindowMode := acDialog
 
Must be a different kind of problem, as the
statement: Me.CmboFilters.Requery
does not clear the combo box when the
"HornetsNet" form is closed?
Bill
 
Requery runs the query underlining a control ie. the one specified in
'controlsource' if your combo is bound to a datasource ('insect' table
perhaps in this case :-)) then the table or query will be refreshed. By
putting 'hornet' in your combo you have updated the current record which
means that the value is saved in the table and consequently displayed in the
combo. If however your combo is unbound then there is nothing to requery and
the text value just stays. Possibly you thought that the requery would work
on the rowsource (though this would have no effect on the contents of the
combo either).
To clear the combo use me.cbofilters = null

Hope this helps you.

Alan
 
Back
Top