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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Before update after update

Status
Not open for further replies.

ZX188

Technical User
Mar 30, 2001
21
US
I have written the code to update a check box in a db based on the input of a certain field on a form. This works ok the problem I have is if the field is changed back the check box does not change based on the data that was in the field before the change. It seams that the data is changed before the code to change the check box back is red. I have tried the before update to change the checkbox back and the after update to change the checkbox to the current state. If I use a second bound text box that this field updates with its data I can use that field to change the checkbox back but it wont work if I make it unbound and I don't need a field in my db that is unnecessary. Any thoughts on how to do this

Thanks
Kevin
 
Let's see. You have a textbox which, when changed/updated, updates a checkbox depending upon the entry in the textbox? Is this correct?

If so, the After Update event should be the place to trigger the checkbox change. This should work every time the data in the textbox changes.

Are you using an If...Then statement to check the value of the textbox? If so, are you sure the statement is correct (no spelling mistakes, etc)? Can you post the code here for us to look at?

HTH
Lightning
 
Private Sub CoreID_AfterUpdate()
Dim StrNoCheck As String
Dim db As DAO.Database
Set db = CurrentDb
If [ServiceType] = &quot;Core&quot; And [CustomerIn] <> &quot;&quot; Then
StrNoCheck = &quot;UPDATE Worksheet SET CoreOwed = 0 WHERE RefrenceNumber = &quot; & Me.[CoreID].Column(0) & &quot;;&quot;
db.Execute StrNoCheck
Else
End If
End Sub

This code works great the problem I have is that if I go back to this field later and change it back I want the check box to go back I use a -1 in place of 0 and put that code in the before update
 
Have you tried using your Before Update code as the ELSE statement in the After Update statement, rather than as a separate procedure? That way, either the first statement or the second statement MUST be evaluated when the textbox is updated, and should set everything as you require.

HTH
Lightning
 
That wont work I need the data that is in the field befor the Update to change the checkbox back
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top