combo box failure
am 08.04.2008 18:05:20 von fredloh
i have a table with a yes/no field call "Edited". i have a button that
runs code to set the "Edited" field of a selected record to "yes". the
code also set the rowsource (using SQL Update and Set statement) of a
combo box to display only records with the "Edited" field = "No". the
button and the combo box are on the same form. the record is selected
from the combo box.
when i step through the code in debug mode, the combo box nicely
displays correctly only records with the "Edited" field = "No". which
could mean nothing wrong with the code? but when i click the button in
open form mode and open the combo box, the combo box displays both the
record with the "Edited" field = Yes and records with "Edited" field =
No. for the record where the "Edited" field has been set to "Yes", the
"edited" field displayed in the combo box shows a "No". the "Edited"
field change to a "Yes" only after i open the combo box twice. the
record with the "Edited" field = "Yes" disappears from the combo box
only after i have set another record's "Edited" field to "yes". this
does not happen all the time though.
what have i done wrong? what is the right way to do it so that the
combo box correctly display only records where "Edited" field ="No" at
all times?
thanks for your help.
Re: combo box failure
am 08.04.2008 18:20:00 von Salad
fredloh@gmail.com wrote:
> i have a table with a yes/no field call "Edited". i have a button that
> runs code to set the "Edited" field of a selected record to "yes". the
> code also set the rowsource (using SQL Update and Set statement) of a
> combo box to display only records with the "Edited" field = "No". the
> button and the combo box are on the same form. the record is selected
> from the combo box.
>
> when i step through the code in debug mode, the combo box nicely
> displays correctly only records with the "Edited" field = "No". which
> could mean nothing wrong with the code? but when i click the button in
> open form mode and open the combo box, the combo box displays both the
> record with the "Edited" field = Yes and records with "Edited" field =
> No. for the record where the "Edited" field has been set to "Yes", the
> "edited" field displayed in the combo box shows a "No". the "Edited"
> field change to a "Yes" only after i open the combo box twice. the
> record with the "Edited" field = "Yes" disappears from the combo box
> only after i have set another record's "Edited" field to "yes". this
> does not happen all the time though.
>
> what have i done wrong? what is the right way to do it so that the
> combo box correctly display only records where "Edited" field ="No" at
> all times?
>
> thanks for your help.
>
I don't know what the combo has to do with displaying records with the
value set to No or Yes.
If you want to see records with Edited set to no you can have the
recordsource do it for you
Select * from Table1 where edited = False
or set the filter programatically.
Me.Filter = "Edited = False"
Me.FilterOn = True
I could have a combo with 3 options; Not Edited, Edited, ShowAll.
In the combo's AfterUpdate event I could do this
Dim strF As String
Select Case Me.ComboBoxName
Case "Not Edited"
strF = "Edited = False"
Case "Edited"
strF = "Edited = True
End Select
Me.Filter = strF
Me.FilterOn = (strF > "") 'ShowAll would be ""
BeYourself
http://www.youtube.com/watch?v=xzNYfMTWpVs
Re: combo box failure
am 09.04.2008 00:02:27 von Larry Linson
The very strong possiblity is that the code does not wait for the update of
the "Edited" Field in the Table to be completed, before resetting the
RowSource of the Combo (and Requerying the Combo?). In debug mode, stepping
through at the speed of the human interface (you), you delay the resetting
of the Combo enough that the update has already completed.
I am a little puzzled at your comment about "(using SQL Update and Set
statement)" in regards to setting the RowSource... my usual Row Source is
either a text Value List, or the text of an SQL Statement, or the text name
of a saved Query... so I'm not sure what you are trying to do.
If you'll post the code... (I think the astrological configuration is not at
its best just now, because our psychic powers to "divine" what code you have
are at a low ebb)... perhaps someone can offer you a suggestion on what to
do.
Larry Linson
Microsoft Access MVP
wrote in message
news:98508790-0880-43b0-9fa5-c7892ad40844@q10g2000prf.google groups.com...
>i have a table with a yes/no field call "Edited". i have a button that
> runs code to set the "Edited" field of a selected record to "yes". the
> code also set the rowsource (using SQL Update and Set statement) of a
> combo box to display only records with the "Edited" field = "No". the
> button and the combo box are on the same form. the record is selected
> from the combo box.
>
> when i step through the code in debug mode, the combo box nicely
> displays correctly only records with the "Edited" field = "No". which
> could mean nothing wrong with the code? but when i click the button in
> open form mode and open the combo box, the combo box displays both the
> record with the "Edited" field = Yes and records with "Edited" field =
> No. for the record where the "Edited" field has been set to "Yes", the
> "edited" field displayed in the combo box shows a "No". the "Edited"
> field change to a "Yes" only after i open the combo box twice. the
> record with the "Edited" field = "Yes" disappears from the combo box
> only after i have set another record's "Edited" field to "yes". this
> does not happen all the time though.
>
> what have i done wrong? what is the right way to do it so that the
> combo box correctly display only records where "Edited" field ="No" at
> all times?
>
> thanks for your help.
>