If Last Record

D

DavidW

How do you when using a continious form:
When you reach the last record, move from that last record to a command
button?
 
J

Jim Allensworth

How do you when using a continious form:
When you reach the last record, move from that last record to a command
button?
You could use the exit event of the last control to move the focus to
another control. The following code will shift the focus to a command
button.

If Me.NewRecord = True And Me.Dirty = False Then
Me.cmdMyButton.SetFocus
End If

- Jim
 
J

John Vinson

How do you when using a continious form:
When you reach the last record, move from that last record to a command
button?

One way is to have a small, one-pixel-square, transparent textbox last
in the tab order. In its GotFocus event check to see if you're at the
last record and move to the next record if not, and setfocus to the
button if so.

How would users add a new record if they can't tab from the last
record into it? Manually click the *> or a NewRecord button? Sounds
like a bit of a hassle!
 
D

DavidW

The record is a prepopulated recordset of all active vehicles(this is
intensional).
There are 6 Different forms (all entries are broken down into different fuel
types, cards, etc.) so the user doesnt have to fiqure out what section thier
in. All textboxes together equal 61, which I believe is to much for one
session.

I don't want new records added unless the unit has been establised at the
front of the program due to invalid data being put in a section that has to
have concurrent information established.

How do you through code, check for the last record?

I am learning just like you did when you started programing, and my
knowledge of syntax and code is improving but still lacks a little.

Thanks For Responding!
David
 
J

John Vinson

The record is a prepopulated recordset of all active vehicles(this is
intensional).
There are 6 Different forms (all entries are broken down into different fuel
types, cards, etc.) so the user doesnt have to fiqure out what section thier
in. All textboxes together equal 61, which I believe is to much for one
session.

I don't want new records added unless the unit has been establised at the
front of the program due to invalid data being put in a section that has to
have concurrent information established.

It sounds like you might want to just set the AllowAdditions property
of the Form to False - the user won't even be presented with the blank
"new" record.
How do you through code, check for the last record?

One way is to use the Form's RecordsetClone:

Public Function AtLastRow(frmF As Form) As Boolean
Dim rs As DAO.Recordset
Set rs = frmF.RecordsetClone
' move to the current record
rs.Bookmark = frmF.Bookmark
' If this is the last record, the recordset will be at EOF
AtLastRow = rs.EOF
Set rs = Nothing
End Function

Then in your Form event you can just check AtLastRecord(Me).
 
D

DavidW

John,
My Form is already set to allow no additions.

And your other suggestion cured my problem. : )

Thanks for the lesson.

Its people like you that help people like me learn so that one day I might
be able to help others in return!

Thanks
David
 
J

John Vinson

Its people like you that help people like me learn so that one day I might
be able to help others in return!

Thank you! But you've discovered the MVP Secret Agenda: getting more
folks hooked so we can quit! <bg>
 
D

Dirk Goldgar

John Vinson said:
It sounds like you might want to just set the AllowAdditions property
of the Form to False - the user won't even be presented with the blank
"new" record.


One way is to use the Form's RecordsetClone:

Public Function AtLastRow(frmF As Form) As Boolean
Dim rs As DAO.Recordset
Set rs = frmF.RecordsetClone
' move to the current record
rs.Bookmark = frmF.Bookmark
' If this is the last record, the recordset will be at EOF
AtLastRow = rs.EOF
Set rs = Nothing
End Function

Then in your Form event you can just check AtLastRecord(Me).

John, is this right? It seems to me that EOF becomes true only if you
move *past* the last record.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top