473,385 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Validate fields on bound form when save record - A 2000

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
1 2256
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bodger | last post by:
Hi, Bearing in mind that I am new to this game, understand very little about SQL and don't work in IT, I was wondering if someone could give me some friendly advice on how to design...
3
by: Young Seeker | last post by:
Hi, I created two forms using forms wizard. One was for a master table that has just an ID and Description column. Another was for a transaction table that has foreign keys from the master table...
2
by: JM | last post by:
Hello, I've created a Querydef in a Form_Load() sub. The form is a subform that no longer has linked child fields. The form is bound to this querydef. When I open the form, the fields are...
22
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
6
by: Mark | last post by:
Hello. I have an MS Access 2000 form whose fields I need to read and write from VBA. The fields are data-bound, using a query that has been defined and saved in my Access database. The query...
8
by: TORQUE | last post by:
Hi, I am having some trouble with recording a field on a form into my Table after formatting it to calculate several fields on the form. If i just put the amount in the field and have it linked...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
1
by: Elainie | last post by:
I have two tables and two forms, "Patient Details", "Placement Details". In the "Patient Details" form, I have the name and addresses fields. I want to update the addresses fields automatically...
5
by: karsagarwal | last post by:
I have a bounded form and after I click the button to update/save. THe fields are still there. Is there a way to clear off the fields in the bounded form. Thanks, SA Here's the code that I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.