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 / March 2005

Tip: Looking for answers? Try searching our database.

Getting the focus to stay in a field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DubboPete - 30 Mar 2005 10:58 GMT
Hi all,

I have tried error trapping a field, whereby if the value of [field2] does
not match [field1] then it should exit sub and stay there for correction.

It (A2K) don't want to do that, and currently I am having to use the
'gotFocus' event of the next field [field3] to force it back to [field2]!

<basic code snippet...  Events... on dirty = true, or AfterUpdate, or Exit>

If me.[field2] <> me.[field1] Then
   msgbox "yada yada.", vbInformation
   me.[field2].setfocus
   Exit Sub
End if
</snippet>

The dang thing moves to [field3] regardless, so at the mo I have [field3]
checking the same values, and...

<snip2>
Private Sub Field3_gotfocus()
   If me.[field2] <> me.[field1] Then
   me.[field2].setfocus
End If
</snip2>

Code above is not copied direct from the event, hence the irregularities
with me and Me instances.... but it hopefully gives the general idea of what
I am trying to achieve...

Is there any reason why the focus cannot stay with [field2]?

your list's own 17th century goat-herder,
DubboPete
tina - 30 Mar 2005 11:12 GMT
try adding the validation to the control's BeforeUpdate event, as

Private Sub Field2_BeforeUpdate(Cancel As Integer)

   If Not (Me!Field2 = Me!Field1) Then
       msgbox "yada yada.", vbInformation
       Cancel = True
   End If

End Sub

hth

> Hi all,
>
[quoted text clipped - 31 lines]
> your list's own 17th century goat-herder,
> DubboPete
DubboPete - 30 Mar 2005 11:14 GMT
thanks Tina,

will keep u informed when I get back to work in the morning, and i get to
try it...

Pete the goat herder

> try adding the validation to the control's BeforeUpdate event, as
>
[quoted text clipped - 47 lines]
>> your list's own 17th century goat-herder,
>> DubboPete
DubboPete - 31 Mar 2005 07:43 GMT
worked fine Tina,

thanks for your help

Pete

> try adding the validation to the control's BeforeUpdate event, as
>
[quoted text clipped - 47 lines]
>> your list's own 17th century goat-herder,
>> DubboPete
 
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.