Gotorecord Next if previous record Less than current

DevinM21

Registered User.
Local time
Today, 05:01
Joined
Dec 4, 2009
Messages
13
I don't know how to word this in a google search, it i kinda early here.

I'm writing this code where if you go from record 1 to reord 2 and record 2 is deleted a mesage box will pop up saying "this record is deleted moving you to the next" and that works, but when i'm at record 5233 and going backwards and record 5232 is deleted it will pop up and say "This record is Deleted moving you to the next" and it moves me back to 5233. So is there like some indentifier to what record you just came from?

If so I can just use and if statement to decide to gotorecord acNext or Acprevious.
 
How bout an "if...Then" or "Select case" using the "Greater then" or "Less then" to determine which code is executed?
 
yes that' exactly what i'm wanting to do.
if [current record number] > [record number you just came from] then
goto Next record
Else if [current record number] < [record number you just came from] then
goto previous record

end if


the problem is idk how to reference [record number you just came from]
 
Am explaining this good? or does anyone not know?

I just need to know if there is a name for a variable that holds what record number yuo just moved from.


i'm on record number 1 in form view, i click arrow at the bottom to goto next, i'm now at record 2. k. I feel confident i'm explaining this clearly so far. now I goto the next record using navigation arrrow, i'm at record number three, then i click arrow to go back, now i'm at record number 2 again, ok then i click navigation arrow next and am at record 3 again. So is there a variable that is somethign like 'RecordYou JustMovedFrom = 2'

That has already been programmed by Access.
 
ok so i sorta made something that kinda works


Code:
Private Sub Form_Current()
If Me.Deleted = True Then
MsgBox "This record is deleted, Moving you to the next"
If Me.CurrentRecord > previousRecord Then
previousRecord = Me.CurrentRecord
DoCmd.GoToRecord acDataForm, "new1", acNext
Else
If Me.CurrentRecord < previousRecord Then
previousRecord = Me.CurrentRecord
DoCmd.GoToRecord acDataForm, "new1", acPrevious
End If
End If
End If
previousRecord = Me.CurrentRecord



Problem with this is if record number 6,7,8 are deleted and you start out on reord number 5 and click next it will get to 9 then and then it will throw a 2105 runtime error, "Can't go to specified record"

Anyone know about that?
 

Users who are viewing this thread

Back
Top Bottom