bookmark

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

Guest

I am using a bookmark to return to edited record after a requery. I get an
error if the record is new. I used:

If Not Me.NewRecord Then
iBook=Me.BookMark
End IF

Me.Requery

If Not Me.NewRecord Then
Me.BookMark=iBook
End IF

But this still results in an error since after the requery the record is not
new. What syntax do I need to accomplish this?

Thanks
 
The way I handle this is to define my own new-record boolean variable. When
you create a new record, set the variable to TRUE. It will stay true until
you reset it yourself at the appropriate time. You may need to dim the
variable at module level, depending its scope of use in the module.

dim new-rec-sw as boolean
new-rec-switch = me.newrecord
If Not Me.NewRecord Then
iBook=Me.BookMark
End IF

Me.Requery

If Not new-rec-sw
Me.BookMark=iBook
End IF
new-rec-sw = false

HTH, UpRider
 
In
smk23 said:
I am using a bookmark to return to edited record after a requery. I
get an error if the record is new. I used:

If Not Me.NewRecord Then
iBook=Me.BookMark
End IF

Me.Requery

If Not Me.NewRecord Then
Me.BookMark=iBook
End IF

But this still results in an error since after the requery the record
is not new. What syntax do I need to accomplish this?

Is this an record that has been edited, but hasn't been saved yet, that
you want to find again after the Requery? If so, it may be simplest to
save the record first, then get its bookmark, then requery. For
example:

Dim vBook As Variant

If Me.Dirty Then
Me.Dirty = False
End If
If Not Me.NewRecord Then
vBook = Me.Bookmark
End If

Me.Requery

If Not IsEmpty(vBook) Then
Me.Bookmark = vBook
End If
 
Back
Top