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
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