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

Access Form TextBox

Status
Not open for further replies.

tony813

Technical User
Dec 28, 2002
14
0
0
US
Working with Access:

and the following is my problem:

ElseIf Tip.text = &quot;&quot; Then <---------------Something abut this line here...
MsgBox &quot;Please Enter a Tip&quot;
Me.Tip.SetFocus

I change the code using the value property. I dont get the error msg. However, it skips the Then MsgBox &quot;Please Enter a Tip&quot; portion.

ElseIf Tip.Value = &quot;&quot; Then
MsgBox &quot;Please Enter a Tip
Me.Tip.SetFocus


I then tested by doing the following....
If Tip.Value = &quot;&quot; Then <----Placed this on watch... and it does state Tip.Value = Null
MsgBox &quot;Please Enter a Tip&quot; <----However, this part is skipped
Me.Tip.SetFocus
Else: MsgBox &quot;What Happen&quot; <----And it does display this msg box
End If

The actual lines of code are the follwoing:

Private Sub Command11_Click()
On Error GoTo Err_Command11_Click

ElseIf Name1.ListIndex = -1 Then
MsgBox &quot;Please select a Name&quot;
Me.Name1.SetFocus
Exit Sub
ElseIf Tip_Type.ListIndex = -1 Then
MsgBox &quot;Please Select a Tip Type&quot;
Me.Tip_Type.SetFocus
Exit Sub
ElseIf Tip.Value = &quot;&quot; Then
MsgBox &quot;Please Enter a Tip&quot;
Me.Tip.SetFocus
Exit Sub
End If

DoCmd.GoToRecord , , acNext

Exit_Command11_Click:
Exit Sub

Err_Command11_Click:
MsgBox Err.Description
Resume Exit_Command11_Click

End Sub


Tony813
 
Hi Tony813,

I'm not entirely sure what is skipped, but I'm guessing that it is the Msgbox AND the Setfocus. The reason is that Tip.Value is NULL but you are checking to see if it is equal to an empty string.

Change it to
Code:
If IsNull(Tip.Focus) Then
.

Although primarily not about Access you might want to read my FAQ on Nulls in the VBA Forum (faq707-3710).

Enjoy,
Tony
 
You are the man.... you have answered... the mystery.... to my question...

thank you... thank you....

Tony813
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top