On Change question

rbinder

rbinder
Local time
Today, 12:53
Joined
Aug 13, 2005
Messages
25
Greetings

I am grappling with a problem with some code I have put into On Change of a field

I set up the field with the following code;

Private Sub Location_Enter()
Dim sqltext

sqltext = "SELECT tbl_Data_Vessel_Barrel_Position.Position "
sqltext = sqltext & "FROM tbl_Data_Vessel_Barrel_Position WHERE (((tbl_Data_Vessel_Barrel_Position.InUse)=No)) "


If IsNothing(Me.Location) Then
Me.Location.InputMask = ">LL00000"
Me.Location.RowSource = sqltext
'Me.Location.LimitToList
Me.Location.Requery
End If


End Sub

This works fine as but the On Change command I use;

Private Sub Location_Change()
Dim db1 As DAO.Database
Dim rst As DAO.Recordset

Set db1 = CurrentDb
Set rst = db1.OpenRecordset("tbl_Data_Vessel_Barrel_Position")
rst.Index = "PrimaryKey"
rst.Seek "=", Me.Location
rst.Edit
rst!InUse = "0"
rst.Update
rst.Close
Set db1 = Nothing
Set rst = Nothing

End Sub

Must assume that the field has been changed is some way.

Can anyone spot or suggest how to rectify this problem.

Thanks

~rbinder
 
On Change

Hi,

In my haste forgot the point;

The on change code seem to run everytime I go in and out of the field whether there is a change or not!

~rbinder
 
Use the After Update event.

RV
 

Users who are viewing this thread

Back
Top Bottom