VB question about last record.

  • Thread starter Thread starter James Mckillop
  • Start date Start date
J

James Mckillop

I am trying to find a line in VB that will let me detect
when my record number says (autonumber) to automatically
goto Previous_record_click, but EOF Is not reconized and

IF Form_KittenMain!RecordNumber = "(AutoNumber)" Then
Previous_Record click
end IF

Does not work either.
Any sugestions this is using access 2000 by the way.

James
 
James Mckillop said:
I am trying to find a line in VB that will let me detect
when my record number says (autonumber) to automatically
goto Previous_record_click, but EOF Is not reconized and

IF Form_KittenMain!RecordNumber = "(AutoNumber)" Then
Previous_Record click
end IF

Does not work either.
Any sugestions this is using access 2000 by the way.

What are you trying to do with this code? If you just want to keep the
user from adding any new records, it would be simplest just to set the
form's AllowAdditions property to No. If for some reason that won't
serve your needs, if you really do need to allow the user to get to the
new record, but then have to move back, you could write (in code on the
form)

If Me.NewRecord Then
Previous_Record_Click
End If
 
Although Access will display the text "(AutoNumber)" in a control bound to
an AutoNumber field when the form is at the new record, that's just for
display - the text box doesn't really contain that value, it's value is
Null. In older versions of Access, we used to use that fact to detect the
new record - only when the form was at the new record could the value of an
AutoNumber field be Null. However, that hasn't been necessary for a long
time now, because Access forms have a NewRecord property that returns True
when the form is at the new record.
 
That worked great. It now bounces it back one record
when it hits the end. This will allow me to force the
user to use the Add new record button to add a record.
Thanks a lot
James
 
James Mckillop said:
That worked great. It now bounces it back one record
when it hits the end. This will allow me to force the
user to use the Add new record button to add a record.
Thanks a lot
James

What would make more sense would be to turn AllowAdditions off and then
have an "Add Record" button that turns AllowAdditions back on and then
takes you to the NewRecord position. In the AfterInsert event you could
then turn AllowAdditions back off.

Doing it that way the [>] button would automatically "Gray out" when on the
last record and the [>*] would always be disabled.
 
Back
Top