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

Blank record

Status
Not open for further replies.

K3ith

Technical User
Oct 26, 2001
16
0
0
US
Hello,

Could someone help, the problem is as follows: I have a textbox within a form that is not allowed to be blank, the user must enter some info before they can save the record. I have validation on the field within the actual table, but what I want to achieve is when the user clicks on the save button a message is displayed saying they need to enter info into the textbox. I have tried the following:

If txtinfo.Value = " " Then
MsgBox "You must enter information"
End if

I have even tried removing the space between the speech marks.

Basically what I want to achieve is if a field is blank (no data) then a message is returned. But to do this through code.

Thanks in advance.
 
In this case, you need the ISNULL function - there is a difference between a BLANK and NULL (no data at all)

Stick this on the EXIT event of the textbox:
-----------------------------------
IF IsNull(me!TxtInfo) then
Msgbox "This field can NOT be left blank. Please make up some spurious data and enter it..."
DoCmd.CancelEvent
Exit Sub
End if
--------------------------------------- Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Thanks, IsNull solved the problem.

Much appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top