Connecting Tech Pros Worldwide Forums | Help | Site Map

Validate fields on bound form when save record - A 2000

L Mehl
Guest
 
Posts: n/a
#1: Nov 12 '05
On my cmdSaveRecord, I check a couple of fields to confirm that an entry has
been made before allowing the Save.

I decided to
- not put validation rules in table structure, and
- validate on Save
to avoid annoying the user if a field was left empty before clicking
cmdSaveRecord

For each field validated in this way, I was getting an error something like
"...does not have the focus ..." until I added

Me.txtBox.SetFocus

before this code

If Len(Me.txtBox.text) = 0 Then
MsgBox "Field Must Have A Value", ...
Exit Sub
End If

The SetFocus technique requires that the cmdSaveRecord be clicked once for
each field tested this way ... not very user-friendly.

Is there a way to avoid this use SetFocus? If it isn't really required,
please tell me what I might be doing wrong.

Thanks for any help.

Larry Mehl




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.562 / Virus Database: 354 - Release Date: 1/16/2004



Wayne Morgan
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Validate fields on bound form when save record - A 2000


To use the .Text property, the control has to have the focus. However, once
the control loses the focus it updates and the data in the .Text property
becomes the .Value property as well and this doesn't require the focus. If
you need to revert back to the previous value before the data is saved to
the table, you can use the .OldValue property.

Remember, on multi-column list boxes and combo boxes, the text value may not
be the value, the value for the bound column associated with the selected
text item is the value.

--
Wayne Morgan
Microsoft Access MVP


"L Mehl" <mehl_nospam@cyvest.com> wrote in message
news:ZAZOb.19793$zj7.14137@newsread1.news.pas.eart hlink.net...[color=blue]
> On my cmdSaveRecord, I check a couple of fields to confirm that an entry[/color]
has[color=blue]
> been made before allowing the Save.
>
> I decided to
> - not put validation rules in table structure, and
> - validate on Save
> to avoid annoying the user if a field was left empty before clicking
> cmdSaveRecord
>
> For each field validated in this way, I was getting an error something[/color]
like[color=blue]
> "...does not have the focus ..." until I added
>
> Me.txtBox.SetFocus
>
> before this code
>
> If Len(Me.txtBox.text) = 0 Then
> MsgBox "Field Must Have A Value", ...
> Exit Sub
> End If
>
> The SetFocus technique requires that the cmdSaveRecord be clicked once for
> each field tested this way ... not very user-friendly.
>
> Is there a way to avoid this use SetFocus? If it isn't really required,
> please tell me what I might be doing wrong.
>
> Thanks for any help.
>
> Larry Mehl
>
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.562 / Virus Database: 354 - Release Date: 1/16/2004
>
>[/color]


Closed Thread