Main Form / ListCount Problem

B

Bob Vance

On my Main Form that stays open I have a list box [lbTaxChange] that is
based on a query it is not Visible but I have another text box that is
visible showing how many are tax Changed.
=[lbTaxChange].[ListCount]
When I go to another form and change the Tax, because my main form is still
open it will not refresh/requery the List box until I close my db and re
open it
 
D

Dirk Goldgar

Bob Vance said:
On my Main Form that stays open I have a list box [lbTaxChange] that is
based on a query it is not Visible but I have another text box that is
visible showing how many are tax Changed.
=[lbTaxChange].[ListCount]
When I go to another form and change the Tax, because my main form is
still open it will not refresh/requery the List box until I close my db
and re open it


First question: is the list box always invisible? If so, why use a list
box instead of a just using a DCount expression in your text box? I can
imagine that possibly you extract other info from this list box; I'm just
asking to make sure there isn't an easier way to do this.

With your current setup, I belived you're going to have to do two things in
the AfterUpdate event of the form where you change the tax: (1) requery the
list box, and (2) requery (or maybe recalc) the text box that displays the
ListCount. But you don't want to do those things if the Main Form is not
open, so you should check that first. Your code in the Tax form might look
something like this:

'----- start of example code -----
Private Sub Form_AfterUpdate()

If CurrentProject.AllForms("Main Form").IsLoaded Then
With Forms("Main Form")
!lbTaxChange.Requery
!txtTaxCount.Requery '*** change to correct name
End With
End If

End Sub
'----- end of example code -----

Note that you may have to change "Main Form" to the name of your form, if
it's not correct, and you probably have to change "txtTaxCount" to the name
of the text box on that form.

If the line

!txtTaxCount.Requery

(with the name corrected) doesn't work, then try this line instead:

.Recalc
 
J

John W. Vinson

On my Main Form that stays open I have a list box [lbTaxChange] that is
based on a query it is not Visible but I have another text box that is
visible showing how many are tax Changed.
=[lbTaxChange].[ListCount]
When I go to another form and change the Tax, because my main form is still
open it will not refresh/requery the List box until I close my db and re
open it

You can explicitly requery the textbox in the AfterUpdate event of the Tax
control.
 
B

Bob Vance

Thanks John, I have tried to requery from the Tax Control but with my Main
Form still open it will not requery........Thanks Bob

John W. Vinson said:
On my Main Form that stays open I have a list box [lbTaxChange] that is
based on a query it is not Visible but I have another text box that is
visible showing how many are tax Changed.
=[lbTaxChange].[ListCount]
When I go to another form and change the Tax, because my main form is
still
open it will not refresh/requery the List box until I close my db and re
open it

You can explicitly requery the textbox in the AfterUpdate event of the Tax
control.
 
J

John W. Vinson

Thanks John, I have tried to requery from the Tax Control but with my Main
Form still open it will not requery........Thanks Bob

Please post your actual code and the names of the relevant forms and controls.
 
B

Bob Vance

Thanks Dirk it is working but I must have to go back to the Tax Button form
again for it to change...Regards Bob

Dirk Goldgar said:
Bob Vance said:
On my Main Form that stays open I have a list box [lbTaxChange] that is
based on a query it is not Visible but I have another text box that is
visible showing how many are tax Changed.
=[lbTaxChange].[ListCount]
When I go to another form and change the Tax, because my main form is
still open it will not refresh/requery the List box until I close my db
and re open it


First question: is the list box always invisible? If so, why use a list
box instead of a just using a DCount expression in your text box? I can
imagine that possibly you extract other info from this list box; I'm just
asking to make sure there isn't an easier way to do this.

With your current setup, I belived you're going to have to do two things
in the AfterUpdate event of the form where you change the tax: (1)
requery the list box, and (2) requery (or maybe recalc) the text box that
displays the ListCount. But you don't want to do those things if the Main
Form is not open, so you should check that first. Your code in the Tax
form might look something like this:

'----- start of example code -----
Private Sub Form_AfterUpdate()

If CurrentProject.AllForms("Main Form").IsLoaded Then
With Forms("Main Form")
!lbTaxChange.Requery
!txtTaxCount.Requery '*** change to correct name
End With
End If

End Sub
'----- end of example code -----

Note that you may have to change "Main Form" to the name of your form, if
it's not correct, and you probably have to change "txtTaxCount" to the
name of the text box on that form.

If the line

!txtTaxCount.Requery

(with the name corrected) doesn't work, then try this line instead:

.Recalc


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
B

Bob Vance

Thanks John..............Bob
-----------------------------
Private Sub cmdModify_Click()


bModify = True
cmdCalculate.Enabled = True
cbGSTOptions.Enabled = True
cmdCalculate.SetFocus

cmdModify.Enabled = False

If CurrentProject.AllForms("frmMain").IsLoaded Then
With Forms("frmMain")
!lbTaxChange.Requery
!tbTaxChange.Requery
End With
End If

End Sub
 
D

Dirk Goldgar

Bob Vance said:
Thanks John..............Bob
-----------------------------
Private Sub cmdModify_Click()


bModify = True
cmdCalculate.Enabled = True
cbGSTOptions.Enabled = True
cmdCalculate.SetFocus

cmdModify.Enabled = False

If CurrentProject.AllForms("frmMain").IsLoaded Then
With Forms("frmMain")
!lbTaxChange.Requery
!tbTaxChange.Requery
End With
End If

End Sub


This is on your Tax Button form? I don't see anything in that code that
would force the form's record to be saved. The record would have to be
saved before even requerying your list box will reflect it. Add a line to
save the form, before the requerying code:
cmdModify.Enabled = False

Me.Dirty = False
 
D

Dirk Goldgar

Bob Vance said:
Dirk, That didnt change the situation......Regards Bob


Did you try using Recalc instead of Requery, like this:

'---- start of code snippet -----
Me.Dirty = False

If CurrentProject.AllForms("frmMain").IsLoaded Then
With Forms("frmMain")
!lbTaxChange.Requery
.Recalc
End With
End If

'---- end of code snippet -----

? If that doesn't work either, then there must be something I don't
understand about how this is set up and what you're doing. Can you step
back and describe in detail what this part of the database is about, how the
relevant tables are set up, how the forms are set up, and what exactly you
are trying to do with them?

Failing that, and if John Vinson doesn't come up with the answer first, then
I invite you to send me a copy of your database to look at. Preferably you
would make a cut-down copy, containing only the elements necessary to
demonstrate the problem, compacted and then zipped to less than 1MB in size
(preferably much smaller). I'll have a look at it, time permitting. You
can send it to the address derived by removing NO SPAM and ".invalid" from
the reply address of this message. If that address isn't visible to you,
you can get my address from my web site, which is listed in my sig. Do
*not* post my real address in the newsgroup -- I don't want to be buried in
spam and viruses.
 
B

Bob Vance

Thanks Dirk. Just did the same as the other. anyway "Murphy's Law" is that
you are going to this form many times so it will refresh its self sooner or
later, maybe because these tax changes are in "Holding Invoices" that have
not been distributed as to why its not working properly..Regards Bob
 
D

Dirk Goldgar

Bob Vance said:
Thanks Dirk. Just did the same as the other. anyway "Murphy's Law" is that
you are going to this form many times so it will refresh its self sooner
or later, maybe because these tax changes are in "Holding Invoices" that
have not been distributed as to why its not working properly..


As I said, there must be something I don't know about the way you have it
set up. I can't tell whether your message is expressing frustration or
resignation. Let me know if you want to pursue it further.
 
B

Bob Vance

Thanks Dirk, No its fine its only a warning and the Invoices are in holding
for a month so , the warning will show soon as I open another
Form.........Regards Bob
 
D

Dirk Goldgar

Bob Vance said:
Thanks Dirk, No its fine its only a warning and the Invoices are in
holding for a month so , the warning will show soon as I open another
Form.........Regards Bob


Okay, Bob. Have a happy Christmas.
 
B

Bob Vance

Thanks Dirk could you look at my post for filtering a listbox
please......Regards Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top