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!

Preventing record navigation

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
How can i prevent record navigation by the user if one or more certain fields have not been filled with data?
 
In design view of the table, set the Required property to Yes and the Allow Nulls value to No for each of the fields you want to apply this test to. Then when anyone adds a new record (directly to the table or in any form) Access will provide an appropriate error message.
 
Another way would be to add code to the form's Before Update event to loop through the fields in the form that you specify as required, and check each for valid entries. If field does not have a valid entry then you can have a msgbox appear then use SetFocus to go directly to the offending field.<br><br>HTH<br>RDH <p>Ricky Hicks<br><a href=mailto: rdhicks@mindspring.com> rdhicks@mindspring.com</a><br><a href= > </a><br>
 
Ricky's method is good if <br>1. people will only be entering into a form, not directly nto the table, and<br>2. if you only have one form for edit or adds of those filelds, or<br>3. if you only want to make certain fields required based on the value of other fields.<br><br>BTW, if you make the field required in the table design, it will automatically carry through to any controls that call that field when you build subsequent forms. If you've <i>already</i> built added the form and added the controls, the design change won't update the existing controls' properties. You would need to delete the control from the existing form and add it again to obtain the new default properties, or of course manually reset the control's properties.
 
As a sidebar, Elizabeth...i though one time in my travels through the Access 97 interface that I came across a button to update all controls based on the fields settings...did i dream this or have you seen this?<br><br>Thanx ;)<br>Drew
 
Drew, I've both heard and read in a number of places that this is <b><i> not</b></i> a capability of Access97. I'd be happy to hear that this is incorrect, if you ever come across that button again. A similar capability that you may be confusing this with was an Access add on (Speed Ferret) for Access 97. With a push of a button you could update object <b><i>names</b></i>, which is very useful. Access 2000 now has this as a built-in capability (object name changes), BTW. It's not as nice as Speed Ferret, but it is infinitely better than manual renaming!
 
I hear ya, I've been looking for it.&nbsp;&nbsp;I thought afterward i might have gotten mixed up with VB 60, but i couldn't find anything like that there either...dangit...<br><br>Haven't heard of speed ferret, but I think i will look it up, since i just got taken on as an access programmer consultant...<br><br>
 
If it's only a data-entry form, open the form with navigation buttons diabled. write an event-procedure for the exit event of the last control.This procedure should check for data presence in all other fields. If yes, enable the navigation buttons.<br><br>Dim ctl as Control<br>&nbsp;&nbsp;&nbsp;For Each ctl In Me.Controls<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If ctl.text = &quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.NavigationButtons = False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.NavigationButtons = True<br>&nbsp;&nbsp;&nbsp;Next<br>End Sub<br><br>This sub-procedure is not valid for all controls. Change the &quot;.text&quot; property to the equivalent of the appropriate command. <p>Narayanan Srinivasan<br><a href=mailto:coolie91@hotmail.com>coolie91@hotmail.com</a><br><a href= > </a><br>Brothers and Sisters from India, if you have any recent news regarding F-1 to H-1B visa transfer, please e-mail me. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top