[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Runt-time error 2108

Posted on 2011-10-25
12
Medium Priority
?
289 Views
Last Modified: 2012-05-12
Experts,
How to I get aound this error "You must save this field before you execute the SetFocus Method:
Private Sub cboStoreManager_BeforeUpdate(Cancel As Integer)
If DCount("*", "tblAssignedStoreEmployees", "StoreManager=" & Me.cboStoreManager) > 0 Then
  MsgBox "This Employee Is Already Assigned To a Store!", vbOKOnly
  Cancel = True
  Me.cboStoreManager.SetFocus
End If
End Sub

Open in new window

0
Comment
Question by:Frank Freese
  • 5
  • 3
  • 2
  • +1
12 Comments
 
LVL 49

Accepted Solution

by:
Dale Fye earned 668 total points
ID: 37027013
just get rid of that line.

Since you are doing this in the BeforeUpdate event of the control, cancelling the operation should set the focus back to that control.
0
 
LVL 75
ID: 37027031
You cannot Set Focus to *any* control in the BeforeUpdate event of a control.

You can if you use the Form Before Update event.

mx
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 668 total points
ID: 37027037
you don't need this   Me.cboStoreManager.SetFocus

the  cancel =true is enough
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Frank Freese
ID: 37027043
mx: in the after update event of the control I set my focus. will that qork?
0
 

Author Comment

by:Frank Freese
ID: 37027047
not qork but OK?
0
 

Author Comment

by:Frank Freese
ID: 37027053
cap: so what you're saying it defaults back to the control?
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 664 total points
ID: 37027060
"mx: in the after update event of the control I set my focus. will that qork?"
No need.  The focus should remain when you set Cancel = True.

mx
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37027063
<cap: so what you're saying it defaults back to the control?>

YES, the focus remain in the control
0
 
LVL 49

Expert Comment

by:Dale Fye
ID: 37027069
Yes,

Which is what I said in the first response.
0
 

Author Comment

by:Frank Freese
ID: 37027074
thanks folks - I had asked this before but forgot....everyone's saying the same thing
0
 
LVL 75
ID: 37027081
And further, you would not want to do that anyway ... because once you update the control, it's time to 'go' .. move on to the next control or whatever.

mx
0
 

Author Closing Comment

by:Frank Freese
ID: 37027087
thank you
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses
Course of the Month18 days, 18 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question