By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,500 Members | 830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,500 IT Pros & Developers. It's quick & easy.

Validate fields on bound form when save record - A 2000

P: n/a
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
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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" <me*********@cyvest.com> wrote in message
news:ZA*******************@newsread1.news.pas.eart hlink.net...
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

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.