Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 10-26-2006, 09:46 PM
wasim_sono wasim_sono is offline Windows XP Access 2007 (version 12.0)
Advanced Beginner
 
Join Date: May 2005
Location: Pakistan
Posts: 68
wasim_sono
Default Sending control to specific control

Dear All

I'm using the following code(which is a part of full code) but this is not working.
Code:
             If CD <> Right(con, 1) Then
                                        MsgBox " the check digit is " & CD
                                        MsgBox "Please Enter Correct Customer No"
                                        CONB.Undo
                                        Cancel = True
                      End if
Here the variable con is equalize with form field "Conb". I'm using this code on after update event of control "CONB". after this code execution the control jumps to next field but I want that if check is wrong then control should stay at CONB field.

Thanks.

Wasim
Reply With Quote
  #2  
Old 11-14-2006, 12:54 PM
Novice
 
Join Date: Nov 2006
Location: Arlington Heights, IL
Posts: 7
ScottG
Default

Are you familiar with the SetFocus property? If the check is wrong then set the focus at ConB.

I believe the code is as simple as:

"ConB.SetFocus"

Thanks,
ScottG
Reply With Quote
  #3  
Old 04-19-2007, 06:19 AM
Novice
 
Join Date: Apr 2007
Location: Portsmouth, VA
Posts: 5
davecass@cox.net
Default

SetFocus will work, but it's not going to consistently work the way you want it to. If the user pressed Tab or Enter to finish the CONB entry, the setfocus will move the cursor back to CONB, but then the tab/enter will be executed, effectively putting your cursor in the next field. The behavior is different, depending on how the user attempted to exit the CONB field.

The consistent way to handle what you're talking about is to move your code from the After_Update event to the Before_Update event. This will prevent the CONB field from losing scope until the problem is resolved.

Take out the UNDO command, as it won't be needed for the Before_Update. The update hasn't happened yet, so there's nothing to undo.

Also note that your command Cancel = True is correct for the Before_Update event (where you're moving your code to). However, it has no effect in the After_Update event where you currently have it, because there's no Cancel parameter in that event.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access - Calendar Control James890 Forms 3 04-01-2009 02:52 PM
Linked control in form Zipster1967 Forms 0 04-14-2007 11:40 AM
No object in this control mtrcar1 Access 0 10-12-2006 03:31 PM
Grid Control - or something like that. rhunt Programming 1 12-15-2005 01:46 PM
Control addressing on subforms JB Access 1 12-09-2005 06:14 PM


All times are GMT -8. The time now is 02:45 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.