A quick bit of help required VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an "after update" event that checks the option chosen in a pop-up form
with the information in a field on the main form. If the department is wrong
it brings up a message. If it is correct it would then set focus on the next
textbox.

My problem is that the first line doesn't work even if the two fields match.
What is wrong?

If Me.dept <> Forms.employee.dept Then
MsgBox "You have selected the wrong department", vbOKOnly, "Invalid Entry!"

Else
Me.password.SetFocus

End If
 
It has just occurred to me that even if someone does choose the wrong
department in the pop-up, they can still move to the password textbox so I
have locked and disabled it.

What I am hoping is that when the correct department is chosen, the password
text box can then be unlocked and enabled for the password to be entered.

What I need to know is whether this change is permanent when the form is
closed. If not I will need to relock and disable the textbox for next time.
Can this be done in a macro?

Or any other suggestion.
 
At the moment I am trying to compare the field in the pop-up with the field
in the main form. I realised this is wrong. What I should be doing is
comparing the field in the pop-up with the same field in the subform, but it
needs to be the LAST record.

Is this possible?

PS sorry for all the messages!
 
Back
Top