Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / September 2007

Cancel=True problems!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
riccifs@tin.it - 29 Sep 2007 20:06 GMT
Hi to everyone,
on the KeyDown Event of my form I have that:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   If KeyCode = vbKeyTab Then
       Screen.ActiveControl.Text =
mixed_case(Screen.ActiveControl.Text)
   End If
End Sub

And on the BeforeUpdate Event I insert that:

Private Sub txtPhone_BeforeUpdate(Cancel As Integer)
If Not rgxValidate(Me.ActiveControl.Text, "\(\d{3}\) \d{3}-\d{4}")
Then
   MsgBox "I don't like " & Me.ActiveControl.Text & "."
   Cancel = True
End If
End Sub

I got both mixed_case and rgxValidate to this web-site http://www.mvps.org/access/.
The problems is:
when I rich the txtPhone and hit the tab, after validated the message
box, the code stops itself.
I'm not very good to VBA coding but I think the problem is the
Cancel=True that stops the KeyDown event
How can I modify all that to make it works together? I need both
rgxValidate and mixed_case functions.
I will really appreciate everyone who would help me!

Bye,
Stefano.
Linq Adams - 29 Sep 2007 23:05 GMT
So, to begin with, you want to format the data in every text box on your form
as if it were a person's proper name? That's what you're doing with the first
piece of code, and this seems a bit odd, to say the least. SHouldn't this be
reserved for the appropriate text box(es) rather than for every text box?

As to the second bit of code; if you see the validation failure messagebox
(which is what  it is, it means that validation has failed) the code is
"stopping" because it is waiting for you to re-enter the phone number
correctly. It will stay at this text box until this correction is made. And
yes, you're correct in that the Cancel = True is the cause for this behaviour.
It forces the user to correct the data. Having validation rules make no sense
unless you're going to force the user to correct their mistakes.

Signature

There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

riccifs@tin.it - 30 Sep 2007 10:01 GMT
On 30 Set, 00:06, "Linq Adams via AccessMonster.com" <u28780@uwe>
wrote:
> So, to begin with, you want to format the data in every text box on your form
> as if it were a person's proper name? That's what you're doing with the first
[quoted text clipped - 15 lines]
>
> Message posted viahttp://www.accessmonster.com

Hi,
in other word the only thing I can do is to use the proper case
function for the appropriate text box(es) rather than for every text
box.
Is there no way to change the second sub so that both of them can work
together?

Bye,
Stefano

P.S.
I'm still not understanding how can I solve the problems!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.