Combo Box Filter and Label (1 Viewer)

Tupacmoche

Registered User.
Local time
Today, 05:13
Joined
Apr 28, 2008
Messages
291
Hi Form Masters,

I have a label that is not refreshing properly. Here is the code:

Me.lblRecCnt.Caption = _
"Record " & Me.CurrentRecord & " of " & Me.Recordset.RecordCount

When, I use navigation buttons to move forward or backwards it updates correctly. Here is where the combo box comes in. It has All, Complete, and Incomplete. But, when I select all it dose not show [Record 1 of 114] but shows [Record 1 of 101], when I select Complete it correctly shows [Record 1 of 5] when I select Incomplete it shows [Record 1 of 101]. There are exactly 114 rows in the table. I have to move to the last record in order to show the correct number of rows. What is wrong? How can I fix this?

Also, I set the default value of the Combo box to 0 (Incomplete) but when the form launches even though 'Incomplete' is selected in the Combo box the form has no rows in it until, I explicitly click the combo box and select Incomplete. Why doesn't it load the Incomplete rows when the form opens? I even put this code into the forms on load event:

CboIsComplete.DefaultValue = 0
Me.Recalc
Me.Refresh
 

isladogs

MVP / VIP
Local time
Today, 10:13
Joined
Jan 14, 2017
Messages
18,216
If there are 101 incomplete and 5 complete, how does that add up to 114?
Neither recalc nor refresh would have any effect at form load.
Requery might be helpful after combo is updated though hard to tell from this info
Consider using DCount instead of a recordset count
 

Tupacmoche

Registered User.
Local time
Today, 05:13
Joined
Apr 28, 2008
Messages
291
That is correct hence my posting the question. I will try DCount but how is it better than RecordSet Count?:(
 

isladogs

MVP / VIP
Local time
Today, 10:13
Joined
Jan 14, 2017
Messages
18,216
So should there be 109 incomplete?
Are there 8 records not being displayed or just not being counted?

However recordset counts will not be correct unless you do MoveLast.
DCount doesn't have that issue

EDIT 2nd issue. Requery
 
Last edited:

Tupacmoche

Registered User.
Local time
Today, 05:13
Joined
Apr 28, 2008
Messages
291
There are a total of 114 rows 5 = 1 (Complete) and 109 = 0 Incomplete. Any thoughts on why the default setting does not work? It is set to '0' Incomplete.
 

moke123

AWF VIP
Local time
Today, 05:13
Joined
Jan 11, 2013
Messages
3,916
Code:
CboIsComplete.DefaultValue = 0
is CboIsComplete a bound combobox?
if not I'm not sure you want defaultvalue.
you may want CboIsComplete = 0 although the 0 kinda confuses me.
what are the fields in the combo?
 

Tupacmoche

Registered User.
Local time
Today, 05:13
Joined
Apr 28, 2008
Messages
291
0 = off or Incomplete, 1 = on or Complete, I think this is standard. It is not bound, I have a simple table two columns Description and Complete

See attached picture.

This is the record source for the combo box. The default value for the back end SQL DB is 0 (zero) Incomplete. So, every row start out incomplete or zero. As users edit and complete the information then they click a check box to show that it's done or complete. The filter lets the user see All rows, complete rows, or incomplete rows. Any idea why the default does not populate when, I open the form? Now, I have to select the default choose before the form is populated.:rolleyes:
 

Attachments

  • CompleteTable.JPG
    CompleteTable.JPG
    20.5 KB · Views: 27

isladogs

MVP / VIP
Local time
Today, 10:13
Joined
Jan 14, 2017
Messages
18,216
I feel I'm saying the same point repeatedly as indeed so are you. Requery.
Or better still if that's how you want the form to be by default, set the record source accordingly at form load
 

JHB

Have been here a while
Local time
Today, 11:13
Joined
Jun 17, 2012
Messages
7,732
Have you actually checked that table only have 0 and 1 in the field?
 

Tupacmoche

Registered User.
Local time
Today, 05:13
Joined
Apr 28, 2008
Messages
291
Yes, the table only has 0 and 1, I created it for this combo box.
 

JHB

Have been here a while
Local time
Today, 11:13
Joined
Jun 17, 2012
Messages
7,732
Could you post your database?
 

Tupacmoche

Registered User.
Local time
Today, 05:13
Joined
Apr 28, 2008
Messages
291
There is a screen shot and complete description of it in the tread.
 

Users who are viewing this thread

Top Bottom