RECORDSET RETURNING FALSE VALUE

  • Thread starter Thread starter dk
  • Start date Start date
D

dk

I need little help from Your side. I have DB to tracking complains of the
owners of the vehicles.
If form NewComplain user shall imput VIN number of the vehicle. In table
Vehicles I have fields Chassis and field OWNER. I using following code to
fill-up field OWNER

Private Sub VIN_LostFocus()

Set db = CurrentDb()
Set rst = db.OpenRecordset("Vehicles", dbOpenDynaset)
rst.FindLast "Chassis = '" & VIN & "'"

Me.OWNER = rst.OWNER
rst.Close
End Sub

The problem is if there is no mach, rst returns some vromg value into field
OWNER.

Thank You very much to help me resolve this.

Regards,
DK
 
You need to test NoMatch after the FindFirst:

rst.FindFirst ...
If rst.NoMatch Then
Me.OWNER = Null
Else
Me.OWNERj = rst!OWNER
End If
 
THNX
this pice of code were missing !
DK
Allen Browne said:
You need to test NoMatch after the FindFirst:

rst.FindFirst ...
If rst.NoMatch Then
Me.OWNER = Null
Else
Me.OWNERj = rst!OWNER
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top