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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controls not refreshing on form (Repaint not working?)

Status
Not open for further replies.

rickj65

Programmer
Jun 5, 2002
79
US
In the FormHeader section of a form, I have 8 unbound comboboxes that are used to filter the form's underlying recordsource upon clicking a button (I dynamically build an underlying SQL statement and apply it to the recordsource of the form). This works fine.

I also have a "Clear" button which is supposed to clear all of the comboboxes of previous values so that the user can enter new values for another filter. I use a For...Next loop to accomplish this as such:

For Each ctl In Me.FormHeader.Controls
If ctl.ControlType = acComboBox Then
ctl.Value = Null
End If
Next
Me.Repaint

This works 90% of the time. The other 10% is a mystery. It seems to not work when a user puts in a filter combination and no records are returned...which I trap with a message. When I step through the code, the process works fine; however, at run-time it doesn't behave as it should.

I've experimented with turning Echo on and off, setting ctl.Text = "", repainting within the For...Next loop, running the loop twice, hardcoding each control name in the procedure without a loop, etc. and I'm stumped.

It almost seems like something is stuck in the buffer somewhere and it won't get released via code.

Any suggestions would be greatly appreciated. Thanks!

 
Instead of repaint, did you look at requery? Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
Requerying the form doesn't affect unbound comboboxes. Requerying the individual comboboxes has no affect on the ctl.Value property (Requery affects the underlying rowsource) of a combobox.

I'm trying to clear the ctl.Value property so that it = Null or "".

Thanks for the suggestion though.

Rick
 
Sorry about that, I missed the "unbound" part... Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top