event when moving to next record

  • Thread starter Thread starter Fredo Vincentis
  • Start date Start date
F

Fredo Vincentis

What is the event in Access forms that is executed when I move to the next
record using the standard navigation? I want a piece of code to be executed
every time a user moves from one record to another.

Thanks.
 
What is the event in Access forms that is executed when I
move to the next record using the standard navigation? I
want a piece of code to be executed every time a user
moves from one record to another.

That would be the Form's Current event. You will find it
on the Form's Properties list. This will fire every time
you change records.
 
Jeff Conrad said:
That would be the Form's Current event. You will find it
on the Form's Properties list. This will fire every time
you change records.

Hmmm... I tried that one. It doesn't work for me. This is an extract of my
code:

Private Sub Form_Current()
Call closeForm
End Sub

Private Sub closeForm()
'disable all textfields
txtPriceOne.Enabled = False
txtPriceTwo.Enabled = False
txtPriceThree.Enabled = False
txtPaid.Enabled = False
txtCommentOne.Enabled = False
txtCommentTwo.Enabled = False
txtCommentThree.Enabled = False
txtInvoiceDate.Enabled = False
txtDueDate.Enabled = False
txtItemOne.Enabled = False
txtItemTwo.Enabled = False
txtItemThree.Enabled = False
cmbClientID.Enabled = False
cmbSalesRepID.Enabled = False
chkAddGST.Enabled = False
btCalculateTotal.Enabled = False
btDueDate.Enabled = False
btEmployer.Enabled = False
'switch close status
chkClosed = True
'change label of close button
btClose.Caption = "Open Invoice"
End Sub
 
Hmmm... I tried that one. It doesn't work for me. This is
an extract of my code:

Private Sub Form_Current()
Call closeForm
End Sub

Private Sub closeForm()
'disable all textfields
txtPriceOne.Enabled = False
txtPriceTwo.Enabled = False
txtPriceThree.Enabled = False
txtPaid.Enabled = False
txtCommentOne.Enabled = False
txtCommentTwo.Enabled = False
txtCommentThree.Enabled = False
txtInvoiceDate.Enabled = False
txtDueDate.Enabled = False
txtItemOne.Enabled = False
txtItemTwo.Enabled = False
txtItemThree.Enabled = False
cmbClientID.Enabled = False
cmbSalesRepID.Enabled = False
chkAddGST.Enabled = False
btCalculateTotal.Enabled = False
btDueDate.Enabled = False
btEmployer.Enabled = False
'switch close status
chkClosed = True
'change label of close button
btClose.Caption = "Open Invoice"
End Sub

That's odd. It would seem that following this code all the
aforementioned controls would be disabled every time you
go to a different record. I assume this is what you want
to see? You must have some way to enable those controls
for the user I presume?

I just did your test and everything worked fine. All the
controls were disabled as I moved through the records.

A couple of quick things:
1. Is this form bound to a table or better still a query?
If this is an unbound form the code you are using will not
work.

2. Put a message box in the code temporarily to see if the
closeForm code is actually firing. Something like so:

Private Sub closeForm()
MsgBox "Hello"
....etc
....etc
End Sub

If you see the message box Hello every time you go to a
different record you know it is working. If not, then
something else is going on. Do this test first before we
proceed further.
 
Back
Top