Access Error 2110

owenpeck

New member
Local time
Today, 14:06
Joined
Oct 20, 2009
Messages
2
Dear all,

Following Office upgrade to MS Access 2010 I have an error (code 2110) when trying to edit a record in a databse which I technically own but which was constructed by an access developer and I sadly cannot work out how to translate other solutions for this error code into my database.

The error message in the database is "database can't move the focus to the control cmdclose"

Apologies if I've not provided the right information as I only construct simple databases but I would be grateful if someone could point me in the right direction for fixing this issue.

The VB code for the action is as follows:

Set frm = Screen.ActiveForm
With frm
Select Case .Name
Case "frmEGIFacultative"
If .Dirty Then .Dirty = False

If .Detail.BackColor = conColour_RW Then
.txtdtmUpdated = Now()
.Dirty = False
AllowFormEdits frm, False
Else
Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT * FROM 1_EGI_Facultative WHERE ID=" & frm.txtID, dbOpenSnapshot)
Set rstNEW = db.OpenRecordset("1_EGI_Facultative", , dbAppendOnly)

If rst.EOF Then
MsgBox "Error Record ID:" & frm.txtID & " Not Found"
Else
rst.MoveFirst
rstNEW.AddNew
For Each fld In rst.Fields
Select Case fld.Name
Case "ID"
Case "OriginalRecordID"
rstNEW("OriginalRecordID") = rst!ID
Case "dtmCreated"
rstNEW("dtmCreated") = Now()
Case Else
rstNEW(fld.Name) = rst(fld.Name)
End Select
Next fld
lngID = rstNEW!ID
rstNEW.Update
strSQL = "INSERT INTO 1_EGI_Facultative_RI" & vbCrLf & _
" (1_EGI_Facultative_ID" & vbCrLf & _
" ,RI_ID" & vbCrLf & _
" ,RI_Share" & vbCrLf & _
" ,RI_Reference" & vbCrLf & _
" ,RI_Contact" & vbCrLf & _
" )" & vbCrLf & _
"SELECT " & lngID & vbCrLf & _
" ,RI_ID" & vbCrLf & _
" ,RI_Share" & vbCrLf & _
" ,RI_Reference" & vbCrLf & _
" ,RI_Contact" & vbCrLf & _
"FROM 1_EGI_Facultative_RI" & vbCrLf & _
"WHERE [1_EGI_Facultative_ID]=" & frm.txtID & vbCrLf
db.Execute strSQL, dbFailOnError

frm.cmdClose.SetFocus
frm.txtdtmUpdated = Null
frm.Dirty = False
AllowFormEdits frm, True
MsgBox "Added ID:" & lngID & " with " & db.RecordsAffected & " RI's"
End If
End If
End Select
End With
TB_EditRecord_exit:
Exit Function

TB_EditRecord_Error:
Select Case Err
Case 2475 ' No Active Form
MsgBox "Please use this print function from your form not the database window.", vbCritical, fstrGetAppName()
Resume TB_EditRecord_exit
Case Else
Select Case fbytErrorMessage(Err, Err.Description, "TB_EditRecord", vbCritical + vbAbortRetryIgnore)
Case vbAbort: Resume TB_EditRecord_exit
Case vbIgnore: Resume Next
Case vbRetry: Resume
End Select
End Select
 
if the command button is not visible, or not enabled, you will not be able to move the focus to that control

if might also be a problem with the control you are currently in - but i think you would get a different message.


maybe the syntax is wrong also. perhaps one of these

frm!cmdClose.SetFocus

or

frm.controls("cmdclose").setfocus
 
You will need to either:

  1. Set the frm.cmdClose.Visible and /or frm.cmdClose.Enabled to True before setting focus
  2. Test whether it is Visible and Enabled and do not set focus of either is false
  3. Add a test in your error handler for 2110 and use Resume Next to ignore the problem.
In general you should try to avoid optioin 3 and only use it as a last resort.
 

Users who are viewing this thread

Back
Top Bottom