Next & Previous buttons don't display data correctly in Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The default Next & Previous Butttons do not retrieve the data correctly from
an Access database - this is also true of the Print Button functionality.
However, the default buttons are not used but custom ones are added, the
data is displayed correctly.
I am unable to find how corect the default buttons.
 
Are you referring to the record navigation buttons at the bottom of the form
next to the record counter? In what way is the data incorrect? What is the
code behind the custom buttons? Did you use a wizard to create the Print
button? What does it do, and what are you expecting instead? What is the
code behind the Print button?
 
Bruce,

I have inherited a small system that was designed by someone who left no
documentation and is no longer contactable.
The data that is displayed incorrectly is either shown as a null field or
the value last entered in that field on the screen is shown (i.e. if a new
was created or record was changed, then whatever was last entered on the
screen on the form in this field, then this value is displayed for all
records). NOTE - it is only display that is incorrect - the database remains
correct. All fields concerned are Unbound fields that exist on other tables,
except one field that exists on the table the form is based upon and is
displayed as a combo box.

The custom ''previous record'' button has the following code :-

Private Sub cmdcalldetailprevious_Click()
On Error GoTo Err_cmdcalldetailprevious_Click


DoCmd.GoToRecord , , acPrevious
Me.Refresh

Exit_cmdcalldetailprevious_Click:
Exit Sub

Err_cmdcalldetailprevious_Click:
Select Case Err.Number
Case Is = 2105
Exit Sub
Case Else
MsgBox Err.Description
Resume Exit_cmdcalldetailprevious_Click
End Select
End Sub



The ''Next Button'' is exactly the same except that word previous is
replaced with the word next.

The custom print button is supposed to print of a report version of the form
where the code is as follows :-


Private Sub cmdPrintCallDetail_Click()
On Error GoTo Err_cmdPrintCallDetail_Click

Dim stDocName As String

stDocName = "rptCallDetails"
DoCmd.OpenReport stDocName, acViewPreview, , "[ID]=[Forms]![frmMain]![ID]"

Exit_cmdPrintCallDetail_Click:
Exit Sub

Err_cmdPrintCallDetail_Click:
MsgBox Err.Description
Resume Exit_cmdPrintCallDetail_Click

End Sub


Would I be correct in thinking thta if the Form error is resolved, this
would then be reflected in the print function too?
FYI - if I take the Print Function from the tool bar then every record is
printed, and again the fields mentioned before are incorrect.

I hope this answers all your questions and provides more clarification to my
problem.

Your help is greatly appreciated,

regards,

C. Stanton
 
Bruce,

I have read my notes and thought that clarification may be needed - my form
has BOTH the default Next & Previous Buttons (the ones showing next to the
record counter) and custom buttons. It is the Standard default ones that dont
work - the custom ones DO work ok.

Appologies for any confusion caused.

C. Stanton said:
Bruce,

I have inherited a small system that was designed by someone who left no
documentation and is no longer contactable.
The data that is displayed incorrectly is either shown as a null field or
the value last entered in that field on the screen is shown (i.e. if a new
was created or record was changed, then whatever was last entered on the
screen on the form in this field, then this value is displayed for all
records). NOTE - it is only display that is incorrect - the database remains
correct. All fields concerned are Unbound fields that exist on other tables,
except one field that exists on the table the form is based upon and is
displayed as a combo box.

The custom ''previous record'' button has the following code :-

Private Sub cmdcalldetailprevious_Click()
On Error GoTo Err_cmdcalldetailprevious_Click


DoCmd.GoToRecord , , acPrevious
Me.Refresh

Exit_cmdcalldetailprevious_Click:
Exit Sub

Err_cmdcalldetailprevious_Click:
Select Case Err.Number
Case Is = 2105
Exit Sub
Case Else
MsgBox Err.Description
Resume Exit_cmdcalldetailprevious_Click
End Select
End Sub



The ''Next Button'' is exactly the same except that word previous is
replaced with the word next.

The custom print button is supposed to print of a report version of the form
where the code is as follows :-


Private Sub cmdPrintCallDetail_Click()
On Error GoTo Err_cmdPrintCallDetail_Click

Dim stDocName As String

stDocName = "rptCallDetails"
DoCmd.OpenReport stDocName, acViewPreview, , "[ID]=[Forms]![frmMain]![ID]"

Exit_cmdPrintCallDetail_Click:
Exit Sub

Err_cmdPrintCallDetail_Click:
MsgBox Err.Description
Resume Exit_cmdPrintCallDetail_Click

End Sub


Would I be correct in thinking thta if the Form error is resolved, this
would then be reflected in the print function too?
FYI - if I take the Print Function from the tool bar then every record is
printed, and again the fields mentioned before are incorrect.

I hope this answers all your questions and provides more clarification to my
problem.

Your help is greatly appreciated,

regards,

C. Stanton


BruceM said:
Are you referring to the record navigation buttons at the bottom of the form
next to the record counter? In what way is the data incorrect? What is the
code behind the custom buttons? Did you use a wizard to create the Print
button? What does it do, and what are you expecting instead? What is the
code behind the Print button?
 
I'm not sure, but I think the default navigation buttons are not working
because they are lacking the Refresh code. I'm not sure why the Refresh
line would make a difference, but it is my guess that it does. I expect
that you have some sort of code that writes the values from unbound text
boxes to the various tables. I inherited just such a database. Not sure
why they didn't just use a query to incorporate all of the fields and then
bind controls to those fields, but there it is. It certainly makes it more
difficult to edit records. The user cannot go back and change a competed
record. For that matter, the user cannot go back and even look at a record.
However, there are other ways such as using the form's Data Entry property,
or not allowing edits or deletions, that could restrict what a user can do
with previous records.
The problem, I think, is that there is not really a previous record, at
least not one containing all of the fields. The unbound controls remain
unbound when you move away from the current record. The fields that were
entered into them when the record was new are now in other tables. The
form's record source does not include those fields, so they cannot show up
on the form.
With my database, in order to see reports for all records I created a query
that incorporates all of the tables and the relationships between them. I'm
not quite sure what you can do about the form. I might try a query that
incorporates all of the fields, then base a form on that instead of on what
you have now. I just don't know how to use code to pull the data back into
the form from various tables that are not part of the record source, if that
is what is needed.
For the report, I would suggest using the query incorporating all of the
tables and fields as the report's record source.
I wish I could be more certain of what I am suggesting here, but the use of
unbound controls for fields that are to be saved is rather beyond the scope
of my abilities. I may be missing the mark with my response, and would
welcome some input from a more experienced user.

C. Stanton said:
Bruce,

I have inherited a small system that was designed by someone who left no
documentation and is no longer contactable.
The data that is displayed incorrectly is either shown as a null field or
the value last entered in that field on the screen is shown (i.e. if a new
was created or record was changed, then whatever was last entered on the
screen on the form in this field, then this value is displayed for all
records). NOTE - it is only display that is incorrect - the database
remains
correct. All fields concerned are Unbound fields that exist on other
tables,
except one field that exists on the table the form is based upon and is
displayed as a combo box.

The custom ''previous record'' button has the following code :-

Private Sub cmdcalldetailprevious_Click()
On Error GoTo Err_cmdcalldetailprevious_Click


DoCmd.GoToRecord , , acPrevious
Me.Refresh

Exit_cmdcalldetailprevious_Click:
Exit Sub

Err_cmdcalldetailprevious_Click:
Select Case Err.Number
Case Is = 2105
Exit Sub
Case Else
MsgBox Err.Description
Resume Exit_cmdcalldetailprevious_Click
End Select
End Sub



The ''Next Button'' is exactly the same except that word previous is
replaced with the word next.

The custom print button is supposed to print of a report version of the
form
where the code is as follows :-


Private Sub cmdPrintCallDetail_Click()
On Error GoTo Err_cmdPrintCallDetail_Click

Dim stDocName As String

stDocName = "rptCallDetails"
DoCmd.OpenReport stDocName, acViewPreview, ,
"[ID]=[Forms]![frmMain]![ID]"

Exit_cmdPrintCallDetail_Click:
Exit Sub

Err_cmdPrintCallDetail_Click:
MsgBox Err.Description
Resume Exit_cmdPrintCallDetail_Click

End Sub


Would I be correct in thinking thta if the Form error is resolved, this
would then be reflected in the print function too?
FYI - if I take the Print Function from the tool bar then every record is
printed, and again the fields mentioned before are incorrect.

I hope this answers all your questions and provides more clarification to
my
problem.

Your help is greatly appreciated,

regards,

C. Stanton


BruceM said:
Are you referring to the record navigation buttons at the bottom of the
form
next to the record counter? In what way is the data incorrect? What is
the
code behind the custom buttons? Did you use a wizard to create the Print
button? What does it do, and what are you expecting instead? What is
the
code behind the Print button?
 
Back
Top