Last Record

  • Thread starter jonesfranckandi
  • Start date
J

jonesfranckandi

Hi everyone,

I have an access form where I have a button that upon clicking on it,
goes to the next record. But I want it to stop at the last record and
perform an action then. can anyone kind enough help me please?.
Thanks in advance!!!!!
 
K

Ken Snell \(MVP\)

Define "last record" -- is it the "last record" that is being displayed in
the form? Or the record with the most recent date/time value in it? Or
something else?

What do you mean "stop at the last record"?
 
J

jonesfranckandi

I mean that When you press the button, you go to the next record until
you reach the last record in the form. But I Do Not want the user to go
beyond that last record. What I want also is that when the user
navigates and reaches the last record in the form, a message comes up
saying "you have reached the last record. This form will now open a
report" and the button(that navigates through the records) is disabled
(so he can't go through).
I hope you do understand my concern. I will appreciate if you van help
me.
Thanks in advance!!!
 
K

Ken Snell \(MVP\)

First, set the form's AllowAdditions property to No. That will prevent the
form from going to a new record as a precaution.

Do you want the message to show when the user tries to move beyond the last
record, or when the user gets to the last record?

Post the code that is in your button's click event procedure.
 
J

jonesfranckandi

Thank you!!!

You are the man. Don't worry about the message bit I sorted it out now.
Do you know how to disable the mousewheel in access?. If so can you
help me?
Thanks in advance!!!!!!
 
R

Rick Brandt

Thank you!!!

You are the man. Don't worry about the message bit I sorted it out
now. Do you know how to disable the mousewheel in access?. If so can
you help me?

Stephen Lebans' web site has a free dll you can use along with some code that
can handle the mousewheel.
 
J

jonesfranckandi

Hi,

You here is the full coding behind my form. Hope you can give me some
tips.
Below is the full coding:


Private Sub CmdSubmit_Click()

'See if there is a record in the text fiel then take action
If IsNull(Me.TxtAnswer) Or Me.TxtAnswer = "" Then
MsgBox "You must at least attemp the question by giving a guest",
vbExclamation, "Answer Required"
Me.TxtAnswer.SetFocus
Exit Sub
End If

'Check if the answer is correct
If Me.TxtAnswer.Value = DLookup("[Answer]", "[Answer]", "[ID]= " &
Forms![Answers5]![ID]) Then
Me.TxtAnswer.SetFocus
MsgBox "Correct, you have scored 5 points." & vbCrLf & vbCrLf & "Try
The Next One!!", vbOKOnly + vbInformation, "Feedback"

DoCmd.GoToRecord acDataForm, "Answers5", acNext
Else
MsgBox "Incorrect, you have scored 0 point." & vbCrLf & vbCrLf & "Try
The Next One!!", vbOKOnly + vbInformation, "Feedback"
DoCmd.GoToRecord acDataForm, "Answers5", acNext
Exit Sub
End If
End Sub
-------------------------------------------------------------------------------------------------------------------------------------

Private Sub Form_Current()
With Me.RecordsetClone
If Me.NewRecord Then
CmdSubmit.Enabled = False
Me!CmdPreviewPrint.Enabled = True
Me!TxtAnswer.Visible = False
Me!Questions.Visible = False
LblMessage.Visible = True
Else
CmdSubmit.Enabled = True
Exit Sub
End If
End With

End Sub
---------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_Load()
'Disable the Preview button
Me!CmdPreviewPrint.Enabled = False
End Sub
----------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
MsgBox "Sorry Mousewheel has been disabled you can't navigate through."
& vbCrLf & vbCrLf & "Give an Answer first", vbOKOnly + vbInformation,
"Information"
Exit Sub
End Sub

There you have it. I hope you can give me some help if there is
anything wrong with it. By the way do you happen to know how to disable
the keypad on the keyboard?.
Thanks in advance!!!!!!!!
 
K

Ken Snell \(MVP\)

Here is modified code for the CmdSubmit_Click and the Form_Current event
procedures:



Private Sub CmdSubmit_Click()

'See if there is a record in the text fiel then take action
If Len(Me.TxtAnswer & "") = 0 Then
MsgBox "You must at least attempt the question by giving a guest", _
vbExclamation, "Answer Required"
Me.TxtAnswer.SetFocus
Else
'Check if the answer is correct
If Me.TxtAnswer.Value = DLookup("[Answer]", "[Answer]", "[ID]= " & _
Forms![Answers5]![ID]) Then
Me.TxtAnswer.SetFocus
MsgBox "Correct, you have scored 5 points." & vbCrLf & vbCrLf & _
"Try The Next One!!", vbOKOnly + vbInformation, "Feedback"
Else
MsgBox "Incorrect, you have scored 0 point." & vbCrLf & vbCrLf & _
"Try The Next One!!", vbOKOnly + vbInformation, "Feedback"
End If
With Me.RecordsetClone
Set .Bookmark = Me.Bookmark
.MoveNext
CmdSubmit.Enabled = Not .EOF
Me!CmdPreviewPrint.Enabled = .EOF
Me!TxtAnswer.Visible = Not .EOF
Me!Questions.Visible = Not .EOF
LblMessage.Visible = .EOF
If .EOF = False Then Me.Recordset.MoveNext
End With
End If
End Sub
-------------------------------------------------------------------------------------------------------------------------------------

Private Sub Form_Current()
CmdSubmit.Enabled = True
End Sub

--

Ken Snell
<MS ACCESS MVP>


Hi,

You here is the full coding behind my form. Hope you can give me some
tips.
Below is the full coding:


Private Sub CmdSubmit_Click()

'See if there is a record in the text fiel then take action
If IsNull(Me.TxtAnswer) Or Me.TxtAnswer = "" Then
MsgBox "You must at least attemp the question by giving a guest",
vbExclamation, "Answer Required"
Me.TxtAnswer.SetFocus
Exit Sub
End If

'Check if the answer is correct
If Me.TxtAnswer.Value = DLookup("[Answer]", "[Answer]", "[ID]= " &
Forms![Answers5]![ID]) Then
Me.TxtAnswer.SetFocus
MsgBox "Correct, you have scored 5 points." & vbCrLf & vbCrLf & "Try
The Next One!!", vbOKOnly + vbInformation, "Feedback"

DoCmd.GoToRecord acDataForm, "Answers5", acNext
Else
MsgBox "Incorrect, you have scored 0 point." & vbCrLf & vbCrLf & "Try
The Next One!!", vbOKOnly + vbInformation, "Feedback"
DoCmd.GoToRecord acDataForm, "Answers5", acNext
Exit Sub
End If
End Sub
-------------------------------------------------------------------------------------------------------------------------------------

Private Sub Form_Current()
With Me.RecordsetClone
If Me.NewRecord Then
CmdSubmit.Enabled = False
Me!CmdPreviewPrint.Enabled = True
Me!TxtAnswer.Visible = False
Me!Questions.Visible = False
LblMessage.Visible = True
Else
CmdSubmit.Enabled = True
Exit Sub
End If
End With

End Sub
---------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_Load()
'Disable the Preview button
Me!CmdPreviewPrint.Enabled = False
End Sub
----------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
MsgBox "Sorry Mousewheel has been disabled you can't navigate through."
& vbCrLf & vbCrLf & "Give an Answer first", vbOKOnly + vbInformation,
"Information"
Exit Sub
End Sub

There you have it. I hope you can give me some help if there is
anything wrong with it. By the way do you happen to know how to disable
the keypad on the keyboard?.
Thanks in advance!!!!!!!!


First, set the form's AllowAdditions property to No. That will prevent
the
form from going to a new record as a precaution.

Do you want the message to show when the user tries to move beyond the
last
record, or when the user gets to the last record?

Post the code that is in your button's click event procedure.
 
J

jonesfranckandi

Hi,

Thank you man your coding is much more direct than mine. Thank you for
your help.
God bless you and sorry for all this questions.

Thanks!!!
Here is modified code for the CmdSubmit_Click and the Form_Current event
procedures:



Private Sub CmdSubmit_Click()

'See if there is a record in the text fiel then take action
If Len(Me.TxtAnswer & "") = 0 Then
MsgBox "You must at least attempt the question by giving a guest", _
vbExclamation, "Answer Required"
Me.TxtAnswer.SetFocus
Else
'Check if the answer is correct
If Me.TxtAnswer.Value = DLookup("[Answer]", "[Answer]", "[ID]= " & _
Forms![Answers5]![ID]) Then
Me.TxtAnswer.SetFocus
MsgBox "Correct, you have scored 5 points." & vbCrLf & vbCrLf & _
"Try The Next One!!", vbOKOnly + vbInformation, "Feedback"
Else
MsgBox "Incorrect, you have scored 0 point." & vbCrLf & vbCrLf & _
"Try The Next One!!", vbOKOnly + vbInformation, "Feedback"
End If
With Me.RecordsetClone
Set .Bookmark = Me.Bookmark
.MoveNext
CmdSubmit.Enabled = Not .EOF
Me!CmdPreviewPrint.Enabled = .EOF
Me!TxtAnswer.Visible = Not .EOF
Me!Questions.Visible = Not .EOF
LblMessage.Visible = .EOF
If .EOF = False Then Me.Recordset.MoveNext
End With
End If
End Sub
-------------------------------------------------------------------------------------------------------------------------------------

Private Sub Form_Current()
CmdSubmit.Enabled = True
End Sub

--

Ken Snell
<MS ACCESS MVP>


Hi,

You here is the full coding behind my form. Hope you can give me some
tips.
Below is the full coding:


Private Sub CmdSubmit_Click()

'See if there is a record in the text fiel then take action
If IsNull(Me.TxtAnswer) Or Me.TxtAnswer = "" Then
MsgBox "You must at least attemp the question by giving a guest",
vbExclamation, "Answer Required"
Me.TxtAnswer.SetFocus
Exit Sub
End If

'Check if the answer is correct
If Me.TxtAnswer.Value = DLookup("[Answer]", "[Answer]", "[ID]= " &
Forms![Answers5]![ID]) Then
Me.TxtAnswer.SetFocus
MsgBox "Correct, you have scored 5 points." & vbCrLf & vbCrLf & "Try
The Next One!!", vbOKOnly + vbInformation, "Feedback"

DoCmd.GoToRecord acDataForm, "Answers5", acNext
Else
MsgBox "Incorrect, you have scored 0 point." & vbCrLf & vbCrLf & "Try
The Next One!!", vbOKOnly + vbInformation, "Feedback"
DoCmd.GoToRecord acDataForm, "Answers5", acNext
Exit Sub
End If
End Sub
-------------------------------------------------------------------------------------------------------------------------------------

Private Sub Form_Current()
With Me.RecordsetClone
If Me.NewRecord Then
CmdSubmit.Enabled = False
Me!CmdPreviewPrint.Enabled = True
Me!TxtAnswer.Visible = False
Me!Questions.Visible = False
LblMessage.Visible = True
Else
CmdSubmit.Enabled = True
Exit Sub
End If
End With

End Sub
---------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_Load()
'Disable the Preview button
Me!CmdPreviewPrint.Enabled = False
End Sub
----------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
MsgBox "Sorry Mousewheel has been disabled you can't navigate through."
& vbCrLf & vbCrLf & "Give an Answer first", vbOKOnly + vbInformation,
"Information"
Exit Sub
End Sub

There you have it. I hope you can give me some help if there is
anything wrong with it. By the way do you happen to know how to disable
the keypad on the keyboard?.
Thanks in advance!!!!!!!!


First, set the form's AllowAdditions property to No. That will prevent
the
form from going to a new record as a precaution.

Do you want the message to show when the user tries to move beyond the
last
record, or when the user gets to the last record?

Post the code that is in your button's click event procedure.

--

Ken Snell
<MS ACCESS MVP>

I mean that When you press the button, you go to the next record until
you reach the last record in the form. But I Do Not want the user to go
beyond that last record. What I want also is that when the user
navigates and reaches the last record in the form, a message comes up
saying "you have reached the last record. This form will now open a
report" and the button(that navigates through the records) is disabled
(so he can't go through).
I hope you do understand my concern. I will appreciate if you van help
me.
Thanks in advance!!!

Ken Snell (MVP) wrote:
Define "last record" -- is it the "last record" that is being
displayed
in
the form? Or the record with the most recent date/time value in it? Or
something else?

What do you mean "stop at the last record"?

--

Ken Snell
<MS ACCESS MVP>

Hi everyone,

I have an access form where I have a button that upon clicking on
it,
goes to the next record. But I want it to stop at the last record
and
perform an action then. can anyone kind enough help me please?.
Thanks in advance!!!!!
 
J

jonesfranckandi

Hi,

Thanks again but I need some more help. You know I have a combo box in
which the list is the name of other forms. The name of my combo box is
CboQuiz.The name of my form is Parameters. But my coding won't work.
here is my code, tell me what is wrong with it.

Private Sub cmdStart_Click()
DoCmd.OpenForm "Forms!Parameters!CboQuiz", acNormal, , , acFormAdd
End Sub

Do you think you can help me with that. Please if you can do. Please!!!

Thanks in advance!!!!!

Hi,

Thank you man your coding is much more direct than mine. Thank you for
your help.
God bless you and sorry for all this questions.

Thanks!!!
Here is modified code for the CmdSubmit_Click and the Form_Current event
procedures:



Private Sub CmdSubmit_Click()

'See if there is a record in the text fiel then take action
If Len(Me.TxtAnswer & "") = 0 Then
MsgBox "You must at least attempt the question by giving a guest", _
vbExclamation, "Answer Required"
Me.TxtAnswer.SetFocus
Else
'Check if the answer is correct
If Me.TxtAnswer.Value = DLookup("[Answer]", "[Answer]", "[ID]= " & _
Forms![Answers5]![ID]) Then
Me.TxtAnswer.SetFocus
MsgBox "Correct, you have scored 5 points." & vbCrLf & vbCrLf & _
"Try The Next One!!", vbOKOnly + vbInformation, "Feedback"
Else
MsgBox "Incorrect, you have scored 0 point." & vbCrLf & vbCrLf & _
"Try The Next One!!", vbOKOnly + vbInformation, "Feedback"
End If
With Me.RecordsetClone
Set .Bookmark = Me.Bookmark
.MoveNext
CmdSubmit.Enabled = Not .EOF
Me!CmdPreviewPrint.Enabled = .EOF
Me!TxtAnswer.Visible = Not .EOF
Me!Questions.Visible = Not .EOF
LblMessage.Visible = .EOF
If .EOF = False Then Me.Recordset.MoveNext
End With
End If
End Sub
-------------------------------------------------------------------------------------------------------------------------------------

Private Sub Form_Current()
CmdSubmit.Enabled = True
End Sub

--

Ken Snell
<MS ACCESS MVP>


Hi,

You here is the full coding behind my form. Hope you can give me some
tips.
Below is the full coding:


Private Sub CmdSubmit_Click()

'See if there is a record in the text fiel then take action
If IsNull(Me.TxtAnswer) Or Me.TxtAnswer = "" Then
MsgBox "You must at least attemp the question by giving a guest",
vbExclamation, "Answer Required"
Me.TxtAnswer.SetFocus
Exit Sub
End If

'Check if the answer is correct
If Me.TxtAnswer.Value = DLookup("[Answer]", "[Answer]", "[ID]= " &
Forms![Answers5]![ID]) Then
Me.TxtAnswer.SetFocus
MsgBox "Correct, you have scored 5 points." & vbCrLf & vbCrLf & "Try
The Next One!!", vbOKOnly + vbInformation, "Feedback"

DoCmd.GoToRecord acDataForm, "Answers5", acNext
Else
MsgBox "Incorrect, you have scored 0 point." & vbCrLf & vbCrLf & "Try
The Next One!!", vbOKOnly + vbInformation, "Feedback"
DoCmd.GoToRecord acDataForm, "Answers5", acNext
Exit Sub
End If
End Sub
-------------------------------------------------------------------------------------------------------------------------------------

Private Sub Form_Current()
With Me.RecordsetClone
If Me.NewRecord Then
CmdSubmit.Enabled = False
Me!CmdPreviewPrint.Enabled = True
Me!TxtAnswer.Visible = False
Me!Questions.Visible = False
LblMessage.Visible = True
Else
CmdSubmit.Enabled = True
Exit Sub
End If
End With

End Sub
---------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_Load()
'Disable the Preview button
Me!CmdPreviewPrint.Enabled = False
End Sub
----------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
MsgBox "Sorry Mousewheel has been disabled you can't navigate through."
& vbCrLf & vbCrLf & "Give an Answer first", vbOKOnly + vbInformation,
"Information"
Exit Sub
End Sub

There you have it. I hope you can give me some help if there is
anything wrong with it. By the way do you happen to know how to disable
the keypad on the keyboard?.
Thanks in advance!!!!!!!!



Ken Snell (MVP) wrote:
First, set the form's AllowAdditions property to No. That will prevent
the
form from going to a new record as a precaution.

Do you want the message to show when the user tries to move beyond the
last
record, or when the user gets to the last record?

Post the code that is in your button's click event procedure.

--

Ken Snell
<MS ACCESS MVP>

I mean that When you press the button, you go to the next record until
you reach the last record in the form. But I Do Not want the user to go
beyond that last record. What I want also is that when the user
navigates and reaches the last record in the form, a message comes up
saying "you have reached the last record. This form will now open a
report" and the button(that navigates through the records) is disabled
(so he can't go through).
I hope you do understand my concern. I will appreciate if you van help
me.
Thanks in advance!!!

Ken Snell (MVP) wrote:
Define "last record" -- is it the "last record" that is being
displayed
in
the form? Or the record with the most recent date/time value in it? Or
something else?

What do you mean "stop at the last record"?

--

Ken Snell
<MS ACCESS MVP>

Hi everyone,

I have an access form where I have a button that upon clicking on
it,
goes to the next record. But I want it to stop at the last record
and
perform an action then. can anyone kind enough help me please?.
Thanks in advance!!!!!
 
K

Ken Snell \(MVP\)

Use the combo box's value in your code:

Private Sub cmdStart_Click()
DoCmd.OpenForm Forms!Parameters!CboQuiz, acNormal, , , acFormAdd
End Sub

--

Ken Snell
<MS ACCESS MVP>


Hi,

Thanks again but I need some more help. You know I have a combo box in
which the list is the name of other forms. The name of my combo box is
CboQuiz.The name of my form is Parameters. But my coding won't work.
here is my code, tell me what is wrong with it.

Private Sub cmdStart_Click()
DoCmd.OpenForm "Forms!Parameters!CboQuiz", acNormal, , , acFormAdd
End Sub

Do you think you can help me with that. Please if you can do. Please!!!

Thanks in advance!!!!!

Hi,

Thank you man your coding is much more direct than mine. Thank you for
your help.
God bless you and sorry for all this questions.

Thanks!!!
Here is modified code for the CmdSubmit_Click and the Form_Current
event
procedures:



Private Sub CmdSubmit_Click()

'See if there is a record in the text fiel then take action
If Len(Me.TxtAnswer & "") = 0 Then
MsgBox "You must at least attempt the question by giving a guest",
_
vbExclamation, "Answer Required"
Me.TxtAnswer.SetFocus
Else
'Check if the answer is correct
If Me.TxtAnswer.Value = DLookup("[Answer]", "[Answer]", "[ID]= " &
_
Forms![Answers5]![ID]) Then
Me.TxtAnswer.SetFocus
MsgBox "Correct, you have scored 5 points." & vbCrLf & vbCrLf &
_
"Try The Next One!!", vbOKOnly + vbInformation, "Feedback"
Else
MsgBox "Incorrect, you have scored 0 point." & vbCrLf & vbCrLf
& _
"Try The Next One!!", vbOKOnly + vbInformation, "Feedback"
End If
With Me.RecordsetClone
Set .Bookmark = Me.Bookmark
.MoveNext
CmdSubmit.Enabled = Not .EOF
Me!CmdPreviewPrint.Enabled = .EOF
Me!TxtAnswer.Visible = Not .EOF
Me!Questions.Visible = Not .EOF
LblMessage.Visible = .EOF
If .EOF = False Then Me.Recordset.MoveNext
End With
End If
End Sub
-------------------------------------------------------------------------------------------------------------------------------------

Private Sub Form_Current()
CmdSubmit.Enabled = True
End Sub

--

Ken Snell
<MS ACCESS MVP>


Hi,

You here is the full coding behind my form. Hope you can give me some
tips.
Below is the full coding:


Private Sub CmdSubmit_Click()

'See if there is a record in the text fiel then take action
If IsNull(Me.TxtAnswer) Or Me.TxtAnswer = "" Then
MsgBox "You must at least attemp the question by giving a guest",
vbExclamation, "Answer Required"
Me.TxtAnswer.SetFocus
Exit Sub
End If

'Check if the answer is correct
If Me.TxtAnswer.Value = DLookup("[Answer]", "[Answer]", "[ID]= " &
Forms![Answers5]![ID]) Then
Me.TxtAnswer.SetFocus
MsgBox "Correct, you have scored 5 points." & vbCrLf & vbCrLf & "Try
The Next One!!", vbOKOnly + vbInformation, "Feedback"

DoCmd.GoToRecord acDataForm, "Answers5", acNext
Else
MsgBox "Incorrect, you have scored 0 point." & vbCrLf & vbCrLf & "Try
The Next One!!", vbOKOnly + vbInformation, "Feedback"
DoCmd.GoToRecord acDataForm, "Answers5", acNext
Exit Sub
End If
End Sub
-------------------------------------------------------------------------------------------------------------------------------------

Private Sub Form_Current()
With Me.RecordsetClone
If Me.NewRecord Then
CmdSubmit.Enabled = False
Me!CmdPreviewPrint.Enabled = True
Me!TxtAnswer.Visible = False
Me!Questions.Visible = False
LblMessage.Visible = True
Else
CmdSubmit.Enabled = True
Exit Sub
End If
End With

End Sub
---------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_Load()
'Disable the Preview button
Me!CmdPreviewPrint.Enabled = False
End Sub
----------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As
Long)
MsgBox "Sorry Mousewheel has been disabled you can't navigate
through."
& vbCrLf & vbCrLf & "Give an Answer first", vbOKOnly + vbInformation,
"Information"
Exit Sub
End Sub

There you have it. I hope you can give me some help if there is
anything wrong with it. By the way do you happen to know how to
disable
the keypad on the keyboard?.
Thanks in advance!!!!!!!!



Ken Snell (MVP) wrote:
First, set the form's AllowAdditions property to No. That will
prevent
the
form from going to a new record as a precaution.

Do you want the message to show when the user tries to move beyond
the
last
record, or when the user gets to the last record?

Post the code that is in your button's click event procedure.

--

Ken Snell
<MS ACCESS MVP>

I mean that When you press the button, you go to the next record
until
you reach the last record in the form. But I Do Not want the user
to go
beyond that last record. What I want also is that when the user
navigates and reaches the last record in the form, a message comes
up
saying "you have reached the last record. This form will now open
a
report" and the button(that navigates through the records) is
disabled
(so he can't go through).
I hope you do understand my concern. I will appreciate if you van
help
me.
Thanks in advance!!!

Ken Snell (MVP) wrote:
Define "last record" -- is it the "last record" that is being
displayed
in
the form? Or the record with the most recent date/time value in
it? Or
something else?

What do you mean "stop at the last record"?

--

Ken Snell
<MS ACCESS MVP>

Hi everyone,

I have an access form where I have a button that upon clicking
on
it,
goes to the next record. But I want it to stop at the last
record
and
perform an action then. can anyone kind enough help me please?.
Thanks in advance!!!!!
 
Top