Setfocus Problem

Tsango

Registered User.
Local time
Today, 00:42
Joined
Mar 31, 2006
Messages
64
If a user enters too many characters into a field I want to display a message and then keep the user in that text box until less characters are entered.

This is the code

Private Sub txtTitle_LostFocus()
txtTitle.Value = LTrim(txtTitle.Value)
If Len(txtTitle.Value) > 50 Then
MsgBox "Title is too long. Can not be more than 50 characters", vbOKOnly, "Title Too Long"
txtTitle.SetFocus
End If
End Sub

The message appears but focus moves to the next text box almost as if the setfocus command has been ignored.

Anyone got any ideas as to why??

Thanks
 
Last edited:
Use the BeforeUpdate event of the control in conjuction with Cancel=True if the condition is not met, the focus will then not move from the field
 
Rich said:
Use the BeforeUpdate event of the control in conjuction with Cancel=True if the condition is not met, the focus will then not move from the field

Your the man Rich

All I need to do now is go through about 30 forms and do this for each text box......Arghhhhh!

Cheers..........
 
Your design now sounds rather suspect, why do you have 30 data entry forms?
 
Rich said:
Your design now sounds rather suspect, why do you have 30 data entry forms?


I have designed a point of sale system for a salon

I do have about 30 forms but they're not all data entry so a slight exageration.

Such forms as

Client details
Employee details
Business Contact details
Product details

Entering sick days, holidays, overtime

Till declaration
Refund
Main payment screen
Entering voucher details
Main Diary
Diary time details for each employee
Sunbed Diary
Entering Sunbed details

There is a complete marketing suite which allows you to pick out certian clients based on type of service/stylist/products purchased, days they come into the salon ect ect, then export their address's and details for a mail merge, or to Excel, or to address labels/envelopes, or a list

Just to name a few of the modules.....!

Although I used to be a programmer working on Finacial software, I started this not knowing Access at all and obviously have done things in the earlier modules that I can now do a lot better so am continually having to go back through old code and re-design it........
 
Yes well in that case I'd rather use a function and the tag property, I'll try and post it later today
 
Rich said:
Yes well in that case I'd rather use a function and the tag property, I'll try and post it later today


That sounds interesting Rich.

I'd appreciate that.

I'd admit that it's not the best designed system in the world and It's rather frustrating finding out how badly I have done things, but highly rewarding when the changes are made. Just seems neverending...!!!

I need to make a start onm the user manual!
 

Users who are viewing this thread

Back
Top Bottom