![]() |
|
|
#1
|
|||
|
|||
|
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
Thanks. Wasim |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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. |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
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 |