xp310
asked on
After Update Code
Hello,
I'm not sure how to write this code.
Here's the code I have in place,...
Private Sub txtAttendanceSubject_After Update()
Me.txtAttendanceNote = 1
End Sub
But here's what I would like,...
Private Sub txtAttendanceSubject_After Update()
Me.txtAttendanceNote = Null
IF txtAttendanceSubject = Any Value, then = 1
IF txtAttendanceSubject = No Value, then = Null
So basically, if txtAttendanceSubject equals a value of any kind, txtAttendanceSubject will ALWAYS = 1
But if there's nothing in txtAttendanceSubject, OR the value has since been removed, THEN it needs to = Null
End Sub
I'm not sure how to write this code.
Here's the code I have in place,...
Private Sub txtAttendanceSubject_After
Me.txtAttendanceNote = 1
End Sub
But here's what I would like,...
Private Sub txtAttendanceSubject_After
Me.txtAttendanceNote = Null
IF txtAttendanceSubject = Any Value, then = 1
IF txtAttendanceSubject = No Value, then = Null
So basically, if txtAttendanceSubject equals a value of any kind, txtAttendanceSubject will ALWAYS = 1
But if there's nothing in txtAttendanceSubject, OR the value has since been removed, THEN it needs to = Null
End Sub
(slight correction, need double quotes)
IF Nz(Me.txtAttendanceSubject , "Wahoo") <> "Wahoo" '<-- Replace "Wahoo" with whatever floats your boat
IF Nz(Me.txtAttendanceSubject
Private Sub txtAttendanceSubject_After Update()
if NZ(Me.txtAttendanceSubject ,"") = "" then Me.txtAttendanceNote = Null else Me.txtAttendanceNote = 1
End Sub
if NZ(Me.txtAttendanceSubject
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just curious if u are always going to set the Subject to 1 or nothing, why dont u create some kind of checkbox instead
ASKER
Jim,
I tried your code in the Before Update - but for my example, I can't tie it to a specific word. So I replaced "wahoo" with "". And in doing that, the code doesn't work & highlights that specific row I changed.
As for the before & after update - I think I have a very different understanding how those events work. To me, it would make sense to put it in the after update. If the code runs "Before" then how is it going to determine the correct answer. It would make sense that it would run "After" to determine if a value of any kind has been entered.
Eh, like I said... I'm sure my sense of what those events do is complete screwed up. :-)
Rockiroads,
I tried your code, but it didn't work for me it just resulted in errors. As for your comment about me changing the values - well your codes are backwards I think.
This is basically what I want...
"IF txtAttendanceSubject = ANY VALUE then txtAttendanceNote will = 1"
So, txtAttendanceNote only signifies a value has been entered into the subject field. if there's no 1, then there shouldn't be a subject.
I tried your code in the Before Update - but for my example, I can't tie it to a specific word. So I replaced "wahoo" with "". And in doing that, the code doesn't work & highlights that specific row I changed.
As for the before & after update - I think I have a very different understanding how those events work. To me, it would make sense to put it in the after update. If the code runs "Before" then how is it going to determine the correct answer. It would make sense that it would run "After" to determine if a value of any kind has been entered.
Eh, like I said... I'm sure my sense of what those events do is complete screwed up. :-)
Rockiroads,
I tried your code, but it didn't work for me it just resulted in errors. As for your comment about me changing the values - well your codes are backwards I think.
This is basically what I want...
"IF txtAttendanceSubject = ANY VALUE then txtAttendanceNote will = 1"
So, txtAttendanceNote only signifies a value has been entered into the subject field. if there's no 1, then there shouldn't be a subject.
This one checks that subject isn't null or blank. If that's true, then note = 1 else note = null
Private Sub txtAttendanceSubject_After Update()
If Not Nz(me.txtAttendanceSubject .value) = "" then
me.txtAttendanceNote.value = 1
else
me.txtAttendanceNote.value = Null
end if
End Sub
Private Sub txtAttendanceSubject_After
If Not Nz(me.txtAttendanceSubject
me.txtAttendanceNote.value
else
me.txtAttendanceNote.value
end if
End Sub
xp310
this is what I thought, Im sure it was a typo
my first post, this should do what u want
Private Sub txtAttendanceSubject_After Update()
if NZ(Me.txtAttendanceSubject ,"") = "" then Me.txtAttendanceNote = Null else Me.txtAttendanceNote = 1
End Sub
did this not work?
my 2nd post was a reflection of what u said in your initial question, but then I queried this - u wanted to update the subject. I thought this was wrong.
this is what I thought, Im sure it was a typo
my first post, this should do what u want
Private Sub txtAttendanceSubject_After
if NZ(Me.txtAttendanceSubject
End Sub
did this not work?
my 2nd post was a reflection of what u said in your initial question, but then I queried this - u wanted to update the subject. I thought this was wrong.
<no comment>
Nic;o)
Nic;o)
Hello All,
Rocki's solution works...do not accept mine as answer as I was not first.
J
Rocki's solution works...do not accept mine as answer as I was not first.
J
Private Sub txtAttendanceSubject_Befor
Me.txtAttendanceNote = Null
IF Nz(Me.txtAttendanceSubject
Me.txtAttendanceSubject = 1
else
Me.txtAttendanceSubject = NULL
end if
End Sub