Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
584
GB
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




 
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
 
I would try check for new record like:

Code:
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
 
Moss100,
what do you get in [tt]Me.Receipt_Number[/tt] 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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top