Restrict entering Null or Empty in Textbox - Access 2007


Joined
Sep 16, 2014
Messages
1
Reaction score
0
Hi,

I'm developing small database to enter plan no for the company.

The Primary Key is Plan_No and entered using a form (unbound text box -> txt_plan_no)

I want to restrict empty or null in the txt_plan_no before go to the next textbox Customer Name.

I use the following coding. It gives the error message box but it always go to the textbox Customer Name without staying focus in txt_plan_no

Private Sub txt_Plan_no_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Or KeyCode = 40 Or KeyCode = 9 Then
'13-enter key|40-down arrow | 9-tab key
If IsNull(txt_Plan_no.Text) Or IsEmpty(txt_Plan_no.Text) Or txt_Plan_no.Text = "" Then
MsgBox "Plan No. cannot be Blank!", vbCritical
txt_Plan_no.SetFocus
End If
End If
End Sub

Please help.

Thanks.

:dance: CoolPra :dance:
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top