INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to Stop ONCurrent event on form crashing when there are no records

How to Stop ONCurrent event on form crashing when there are no records

(OP)
Hello, I have a form which uses the oncurrent event to set a value.

CODE -->

If Nz(Me.Receipt_Number) <> "" Then
    Me.txt_highlight_record_header = Me.Receipt_Number
  End If 

The code works fine UNLESS there are No records in the recordset.

I want to quit the sub if there are no records so the code does not crash. I was hoping the NZ would work, but sadly not.

Thanks Mark




RE: How to Stop ONCurrent event on form crashing when there are no records

Maybe you could try a dcount of the table/query and use >0 or instead of nz try

If not isnull(Me.Receipt_Number) Then

RE: How to Stop ONCurrent event on form crashing when there are no records

I would try check for new record like:

CODE --> vba

If Not Me.NewRecord Then
    If Nz(Me.Receipt_Number,"")  <> "" Then
        Me.txt_highlight_record_header = Me.Receipt_Number
    End If 
End If 

Duane
Hook'D on Access
MS Access MVP

RE: How to Stop ONCurrent event on form crashing when there are no records

Moss100,
what do you get in Me.Receipt_Number when "there are No records in the recordset"? You may be evaluating the wrong 'piece' in your IF statement...

Have fun.

---- Andy

There is a great need for a sarcasm font.

RE: How to Stop ONCurrent event on form crashing when there are no records

I'm not even sure if you can reference a bound field to check for null, if no records are brought into the form.
sxschech touched on this already.

Maybe try this:

http://www.fontstuff.com/mailbag/qaccess04.htm


ATB,

Darrylle

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close