A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

require value error message



 
 
Thread Tools Display Modes
  #1  
Old February 5th, 2010, 05:30 PM posted to microsoft.public.access.forms
EddWood[_2_]
external usenet poster
 
Posts: 25
Default require value error message

Hi Guys,

I have a form of which one of the fields is a required field and just
wondering how/ where I put the code to present a message box if they fail to
enter a value. I was going to use:


If MsgBox("This is a required field, " & _
"Have you entered some details?.", vbYesNo) = vbYes Then
End If

But am unsure where I should place this? I am using a SQL BE with Access FE
and currently if the user tries to leave the field blank they get a very
unfriendly error message.

Can anyone advise please

  #2  
Old February 5th, 2010, 11:17 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default require value error message

Well, you don't validate whether or not a control has data in it by asking
the user, you check the control:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.YourTextBoxName = "" Or IsNull(Me.YourTextBoxName) Then
MsgBox "You Must Fill In the " & YourTextBoxName & " Field!"
Cancel = True
YourTextBoxName.SetFocus
End If
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201002/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:58 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.