form doesn't update!!!!!

  • Thread starter Thread starter manish
  • Start date Start date
M

manish

I have a form setup having a sub-form which is not the
case of a problem. However i have another form in the
header section which lists only one field (the last
invoice no - raised) from a query. This field is only for
information purpose - so that i can know the next number
to be put on the invoice.
Once the main form is loaded it shows the correct no -
that is the last invoice no. But when i go on adding the
records the field is not updated. Only when i exit the
form and start again does it show the correct invoice no.
I also do not want to put it in my tab order - i.e. I do
not want it to gain focus.
Any way around for these!!!! Please advice..
VBA coding is not my cup of tea.
thanks
-----manish---
 
manish said:
I have a form setup having a sub-form which is not the
case of a problem. However i have another form in the
header section which lists only one field (the last
invoice no - raised) from a query. This field is only for
information purpose - so that i can know the next number
to be put on the invoice.
Once the main form is loaded it shows the correct no -
that is the last invoice no. But when i go on adding the
records the field is not updated. Only when i exit the
form and start again does it show the correct invoice no.
I also do not want to put it in my tab order - i.e. I do
not want it to gain focus.
Any way around for these!!!! Please advice..
VBA coding is not my cup of tea.
thanks
-----manish---

Is this a subform in the form's header, or a text box that uses a
DLookup? Whichever it is, probably you need to explicitly requery it
whenever you add or delete records. The code would be something like

Me!NameOfControl.Requery

where "NameOfControl" is the name of the subform control (on the main
form), if that's what it is, or the name of the text box.
 
Dear Dirk,
It is another form that is not linked to the main form but
it contains a text box which shows information from a
query. Also where should i put this little code which u
have provided.
Also thanks a lot for posting ur reply so fast.
manish
 
manish said:
Dear Dirk,
It is another form that is not linked to the main form but
it contains a text box which shows information from a
query. Also where should i put this little code which u
have provided.
Also thanks a lot for posting ur reply so fast.
manish

I'm not sure what you mean when you say "It is another form that is not
linked to the main form", but I think you mean that it is a subform on
the main form with no Link Master/Child Fields. That means that the
form object is actually displayed in a subform control on the main form.

Suppose that subform control is named "sfLastInvoiceNo". You would put
the code to requery it in both the AfterInsert and AfterDelConfirm
events of whatever form is being used to add invoices. It isn't clear
from your description whether this is the main form itself, or another
subform on that form.

If it's the main form itself, you would add event procedures like these
to the main form:

Private Sub Form_AfterInsert()
Me!sfLastInvoiceNo.Requery
End Sub

Private Sub Form_AfterDelConfirm()
Me!sfLastInvoiceNo.Requery
End Sub

(Note: if you don't allow invoices to be deleted, you don't need to use
the AfterDelConfirm event.)

If, on the other hand, the invoices are being added on a subform of the
main form -- the same main form that also contains sfLastInvoiceNo --
then you have to go up through the subform's Parent property to the main
form, like this:

Private Sub Form_AfterInsert()
Me.Parent!sfLastInvoiceNo.Requery
End Sub

Private Sub Form_AfterDelConfirm()
Me.Parent!sfLastInvoiceNo.Requery
End Sub
 
Dear Dirk,
Thank U Very Very much. Your solution really worked for me.
If really it weren't for U people, people like us would
have died of frustation. thank U for ur response.
manish
 
Back
Top