Custom Navigation buttons

AnnPhil

Registered User.
Local time
Today, 16:58
Joined
Dec 18, 2001
Messages
246
I have custom navigation buttons on my form with a calculated field that counts the records. It works great except when I go to add a new record. The field that calculates the records doesn’t calculate correctly until after I exit the record and go back. I would like to figure out a way to get the calculation to work correctly without leaving the record. Here is an example of my form.
I have three buttons, Go to Previous Record, Go to Next Record, and Add New Record button. Then I have a field that calculates the current record and the total number of records. Example 3 of 3, 2 of 3, 1 of 3. In my case I want the most current record to show first. My problem starts when I click the Add New button, the calculated field changes to 0 of 3 when it should say 4 or 4. I am sure it has to do with the fact that a new record is in the making and until it is saved the calculation can not be accurate. I tried adding code to save record and requery the calculated field in the On click of the Add New Record button but that didn’t work. Any suggestions on how I can make this less confusing when entering a new record.

Here is the calculated field:
=Count(*)-[CurrentRecord]+1 & " of " & Count(*)
 
My example uses the OnCurrent event. The label is named "lRecordXofY".

Private Sub Form_Current()
If Me.NewRecord Then
Me.lRecordXofY.Caption = "New Record (" & DCount("*", "TableB") & " existing records)"
Else
Me!lRecordXofY.Caption = "Record " & [CurrentRecord] & " of " & DCount("*", "TableB")
End If
End Sub

This will put the record info in the forms caption...
If Me.NewRecord Then
Me.Form.Caption = "Your Form Name - New Record (" & DCount("*", "TableB") & " existing records)"
Else
Me.Form.Caption = "Your Form Name - Record " & [CurrentRecord] & " of " & DCount("*", "TableB")
End If

HTH
 

Users who are viewing this thread

Back
Top Bottom