"After Update" to recognise blanks

penfold1992

Registered User.
Local time
Today, 22:34
Joined
Nov 22, 2012
Messages
169
i have a dropdown menu which has this code set into "After Update"
Code:
Me.iOperatorsName = Me.iOperatorsCode.Column(1)

this works fine for the most part, It shows me what i selected in iOperatorsCode and gives me the 2nd column of the table which is the Operators Name.

however I am trying to correct it slightly...
If I remove the operator number and try to just leave it blank, the iOperatorsName doesnt change. I have tried to include this...

Code:
If Me.iOperatorsCode = "" Then
Me.iOperatorsName = ""
End If
Me.iOperatorsName = Me.iOperatorsCode.Column(1)

however this also doesnt pick up when something has been removed in the field. Is there any work around?
 
Try the Nz(Me.iOperatorsCode.Column(1),"") instead of " " for your me.iOperatorsName
 
both of these are not working. I understand what you mean Pat however it still doesnt appear to recognise when I select the cell hit backspace and then hit enter.
If a cell is empty and you hit enter does it not trigger the "After Update" event? as that is what appears to be happening.
 
If a cell is empty and you hit enter does it not trigger the "After Update" event?
No AfterUpdate is triggered every time after the value has been changed.. Try an If Else structure instead of a normal If..
Code:
If Len(Me.iOperatorsCode & vbNullString) = 0 Then
    Me.iOperatorsName = ""
Else
    Me.iOperatorsName = Me.iOperatorsCode.Column(1)
End If
Try and see if it works..
 
try this code for your project



If IsNull(iOperatorsCode) Then
Me.iOperatorsName = ""
End If
Me.iOperatorsName = Me.iOperatorsCode.Column(1):cool::cool:
 
this worked for what I want it to do

no need for cancel because it isnt going in anywhere anyway XD

Code:
Private Sub iOperatorsCode_AfterUpdate()
If Len(Me.iOperatorsCode & vbNullString) = 0 Then
    Me.iOperatorsName = ""
Else
    Me.iOperatorsName = Me.iOperatorsCode.Column(1)
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom