Forced Data Entry in a form

mavver

Registered User.
Local time
Today, 23:07
Joined
Jan 12, 2007
Messages
28
Hello

I have been asked to make sure that a "Query Code" is inputted onto a form that only one user uses.

I was wondering if it was possible to force a user to enter some data in a text box on a form, and to not allow them to save or process the work any further until this alpha numeric field had some data within it.

Ta for any help

Mav
 
In the table for this data (field) REQUIRED properties put YES.
 
Ta for the reply but for some reason this didnt work :(

When I go into the form it allows the user to move through the records and leaves the field blank

In the Design View of the table I have the following selected

Required=Yes
Allow Zero Length=No
Indexed=Yes(No Duplicates)

Ta

Mav
 
If you want to force them to fill it out before doing anything else on the form, in the form's Activate event you can put

Me.YourTextBoxControl.SetFocus

and in the text box's On Lost Focus event put

If IsNull(Me.YourTextBoxNameHere) Or Me.YourTextBoxNameHere = "" Then
...whatever you want to tell them in a message box here
Me.YourTextBoxName.SetFocus
End If

Now, you need to give them an "out" if they don't want to fill it out otherwise they could get totally stuck and have to create a record when they don't really want to. You could display a message box and tell them that field is required and do they want to try again. If not, then use

Me.Undo to undo all of the fields and record.
 
Bob

You are a star, if I wasn't on a completely different continent I would buy you a beer. All I can do is add to that repuation thing.

Ta Loads

Mav
 
Bob

You are a star, if I wasn't on a completely different continent I would buy you a beer. All I can do is add to that repuation thing.

Ta Loads

Mav


And if I drank beer, which I don't (have Diabetes), that would be great.

But, the thank you is enough.
 
If you want to force them to fill it out before doing anything else on the form, in the form's Activate event you can put

Me.YourTextBoxControl.SetFocus

and in the text box's On Lost Focus event put

If IsNull(Me.YourTextBoxNameHere) Or Me.YourTextBoxNameHere = "" Then
...whatever you want to tell them in a message box here
Me.YourTextBoxName.SetFocus
End If

Now, you need to give them an "out" if they don't want to fill it out otherwise they could get totally stuck and have to create a record when they don't really want to. You could display a message box and tell them that field is required and do they want to try again. If not, then use

Me.Undo to undo all of the fields and record.
Hi Bob, I am new to all this Forms/Reports etc.
I am trying to get your solution to work but Access keeps telling me that it can't find a the Macro. You couldn't give me an idiots guide to how to input this code? and where?

Thanks

Stem
 
Private Sub PermitToWorkMaster_Activate()

Me.PermitToWorkMaster.SetFocus

End Sub

Private Sub LocationofWork_LostFocus()

If IsNull(Me.LocationofWork) Or Me.LocationofWork = "" Then MsgBox ("Sorry")
Me.LocationofWork.SetFocus

End If

End Sub

My Form is called PermitToWorkMaster and the initial field name is LocationOfWork.

Above is an extract from the VBA, I am ok with the 'Events' windows etc. I just need the form to stop users from missing out a textbox.
 
i'm pretty sure that when i wanted a field filled, i made the field "required" way back in the table design, then when the field showed in the form, it was required by default and didn't even need focus...
 

Users who are viewing this thread

Back
Top Bottom