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 » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help



 
 
Thread Tools Display Modes
  #1  
Old June 8th, 2004, 06:55 PM
Ken
external usenet poster
 
Posts: n/a
Default Help

Ok, I have created a form with various fields. I would like to make certain
fields required information. In other words a certain field would require
you to put information into before you can close the form or move to the
next field.

thanks for you help


  #2  
Old June 8th, 2004, 08:47 PM
John Vinson
external usenet poster
 
Posts: n/a
Default Help

On Tue, 8 Jun 2004 13:55:37 -0400, "Ken" jeepdakota(NO
wrote:

Ok, I have created a form with various fields. I would like to make certain
fields required information. In other words a certain field would require
you to put information into before you can close the form or move to the
next field.

thanks for you help


Two ways (at least) to do this:

- Open the Table which will contain this data and select each of these
fields; set the field's Required property to True.

- For a friendlier error message, use the Form's BeforeUpdate event.
Invoke the Code Builder and put code like

Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim iAns As Integer
If IsNull(Me!txtReqFieldA) Then
iAns = MsgBox("Please fill in Field A; or Cancel to clear form", _
vbOKCancel)
If iAns = vbOK Then
Cancel = True ' cancel the update to the table
Me!txtReqFieldA.SetFocus ' move the user to the control
Else
Me.Undo ' erase the entire form to start over
Cancel = True
End If
End If
End Sub


John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 




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 07:50 PM.


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