Run-Time Error 2115

R

Rick A

I've done some research on 2115 errors cannot figure this out. In Access
2000, I've created form with a subform.

Here's the three pieces of code where I think the problem resides. The 2115
error happens after I click cboSelectRegistrationNumber, then cmdAddClass,
then cmdApply, then cboSelectRegistrationNumber again. The key seems to be
the cmdAddClass code. See below, I highlighted the line of code where the
program stops because of the 2115 error.

If I click cboSelectRegistrationNumber, then cmdApply, then the
cboSelectRegistrationNumber again I do not receive the error. The same line
of code is executed again with no issues.

I've tried removing the RunCommand acCmdSaveRecord, having read about this
but that does not fix the issue. There has to be something in the
cmdAddClass routine but I cannot find it. Does anyone have any ideas I can
try? By the way, this function - Call AddABNtoDatabase(Me!DogID,
Me!lstArmBandNumber) needs the subform record to be committed to the
database or it abends. If I can figure out the 2115 error I think I can
figure everything out.

Thanks,

Rick

****ONE****
Private Sub cmdApply_Click()
MsgBox Me!txtRegisteredName & " has been updated", vbOKOnly +
vbInformation, "Updated"
Me!lstArmBandNumber.RowSource = ""
Me!lstDogEntry.RowSource = ""
Me.RecordSource = ""
Me!txtClassesFor.Visible = False
Me!txtEntryFor.Visible = False
EnableControls Me, acHeader, True
Me!cboSelectRegisteredName.SetFocus
Me!cmdApply.Enabled = False
Me!cmdCancel.Enabled = False
Me!pgeEntryInformation.Visible = True
Me!tabEntry.Value = 0
EnableControls Me, acDetail, False
EnableControls Me!fsubUniversalGenericEntryDogEvent.Form, acDetail,
False
End Sub

****TWO****
Private Sub cmdAddClass_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim blnAddedClasses As Boolean

' Put in Entry Date - do this first to add the row to trelDogEvent
Me!fsubUniversalGenericEntryDogEvent.Form!txtEntryReceivedDate = Date
Me!fsubUniversalGenericEntryDogEvent.SetFocus
Me!fsubUniversalGenericEntryDogEvent.Form!txtEntryReceivedDate.SetFocus
RunCommand acCmdSaveRecord ' should save the information on the subform

blnAddedClasses = False
Application.Echo False, "Adding Classes..."
Set dbs = CurrentDb()
If Me!lstQuickEntry.ItemsSelected.Count > 0 Then
Set ctl = Me!lstQuickEntry
For Each varItm In ctl.ItemsSelected
strSQL = "SELECT tblTitleEvent.TitleEventDateID,
tblTitleEvent.TitleID, " & _
"qrySelectTitle.LevelID, qrySelectTitle.DivisionID, " & _
"qrySelectTitle.LevelName, qrySelectTitle.DivisionName " & _
"FROM qrySelectTitle INNER JOIN tblTitleEvent ON " & _
"qrySelectTitle.TitleID = tblTitleEvent.TitleID " & _
"WHERE qrySelectTitle.LevelID=" & ctl.Column(0, varItm) & "
" & _
"AND qrySelectTitle.DivisionID=" & ctl.Column(1, varItm)
Set rst = dbs.OpenRecordset(strSQL)
With rst
If ValidJumpHeight(!LevelName, !DivisionName) Then
While Not .EOF
Call AddDogEntry(Me.Name, _
Me!DogID, _
!TitleID, _
!TitleEventDateID, _
Me!lstJumpHeight.Column(0))
.MoveNext
blnAddedClasses = True
Wend
End If
End With
Next varItm
Else
If Me!lstTitleList.ItemsSelected.Count > 0 Then
Set ctl = Me!lstTitleList
For Each varItm In ctl.ItemsSelected
strSQL = "Select LevelName, DivisionName " & _
"From qrySelectTitle " & _
"Where TitleID = " & ctl.Column(0, varItm)
Set rst = dbs.OpenRecordset(strSQL)
With rst

If ValidJumpHeight(!LevelName, !DivisionName) Then
' add this entry for the dog to the database
Call AddDogEntry(Me.Name, _
Me!DogID, _
ctl.Column(0, varItm), _
ctl.Column(1, varItm), _
Me!lstJumpHeight.Column(0))
blnAddedClasses = True
End If
End With
Next varItm
Else
MsgBox "Please Select a Quick Entry Item " & vbCrLf & vbCrLf & _
" or a Date and Title", vbOKOnly + vbInformation, "Missing
Information"
End If
End If
rst.Close
dbs.Close
Set rst = Nothing
Set dbs = Nothing

If blnAddedClasses Then
Me!lstArmBandNumber.RowSource = RemoveABNListBox(Me!lstArmBandNumber)
Me!lstArmBandNumber.RowSource = _
AddToABNListBox(, Me!lstArmBandNumber.RowSource,
Me!lstJumpHeight.Column(0))
Call AddABNtoDatabase(Me!DogID, Me!lstArmBandNumber)
Call DogDateLastEntered(Me!DogID, Me!txtOrganizationCD,
Me!txtApplicationTypeCD)
Call OwnerDateLastEntered(DLookup("OwnerID", "tblDog", "DogID=" &
Me!DogID), _
Me!txtOrganizationCD, Me!txtApplicationTypeCD)
End If

Application.Echo True

Me!lstDogEntry.Requery

End Sub

****THREE****
Private Sub cboSelectRegistrationNumber_AfterUpdate()
Call AfterSelectionRoutine("cboSelectRegistrationNumber")
End Sub
Function AfterSelectionRoutine(strControl As String) As String
' this routine executes after a dog is selected.
Application.Echo False, "thinking...."

' turn the controls on for the detail section of the form,
' set focus, turn off the controls for the header section,
' enagle the cancel button and the apply button
EnableControls Me, acDetail, True

Me!txtClassesFor.Visible = True
Me!txtEntryFor.Visible = True

If Me!fsubUniversalGenericEntryDogEvent.SourceObject = "" Then
Me!fsubUniversalGenericEntryDogEvent.SourceObject =
"fsubUniversalGenericEntryDogEvent"
Select Case Me!txtOrganizationCD
Case "CKC"
Me!fsubUniversalGenericEntryDogEvent.Form!txtEntryReceivedDate.Format
= "dd/mm/yyyy"
Case "AKC"
Me!fsubUniversalGenericEntryDogEvent.Form!txtEntryReceivedDate.Format
= "mm/dd/yyyy"
End Select
End If

' finally enable the controls on the dog event subform
' EnableControls fsubUniversalGenericEntryDogEvent.Form, acDetail, True

' populate the event dates listbox one time after load
' this will speed up initial load of the form.
If Me!lstEventDates.RowSource = "" Then
strSQL = "SELECT EventDateID, " & _
"IIf(dLookup('OrganizationCD','qrySelectControlApplicationData')='CKC','#'
& EventDateDescription & ' ' &
Format(EventDate,'dddd'),Format(EventDate,'ddd mmm-dd-yyyy')) AS
FormatedEventDate, " & _
"EventDate " & _
"FROM qrySelectEventDate; "
Me!lstEventDates.RowSource = strSQL
' also populate title list listbox based on first row of the
' event dates listbox and after the first load of the event date
strSQL = "SELECT [TitleID], [TitleEventDateID], [Title], [EventDateID],
[LevelName], [DivisionName] " & _
"FROM qrytblTitleEvent WHERE EventDateID=" &
Me!lstEventDates.ItemData(0)
Me!lstTitleList.RowSource = strSQL
Me!lblTitlesFor.Caption = "Titles for " &
Format(Me!lstEventDates.Column(2, 0), "dddd dd-mmm-yyyy")

Me!lstJumpHeight.RowSource = "qrySelectJumpHeight"

Me!lstJumpHeightISC.RowSource = "qrySelectJumpHeightISC"

Me!lstQuickEntry.RowSource = "qrySelectQuickLinkList"
Me!txtEntryFor.Visible = True
Me!txtClassesFor.Visible = True
Me!lblTitlesFor.Visible = True
End If

' position on the first row of the event dates listbox
' Me.lstEventDates = Me.lstEventDates.ItemData(0)


' Set up the dog entry listbox based on what dog was selected
strSQL = "SELECT DogID, TitleEventDateID, EventID, " & _
"Format([EventDate],'ddd dd-mmm-yyyy') AS [Event Date], " & _
"EventDateDescription as [Trial Number], TitleAbbreviated as
[Title], " & _
"JumpHeightCD as [Jump Height] " & _
"FROM qrySelectDogEntry " & _
"WHERE DogID = " & Me.Controls(strControl).Value & " and " & _
"EventID = " & Me!txtEventID & " " & _
"ORDER BY EventDate, EventDateDescription, CatalogSortOrder"
Me!lstDogEntry.RowSource = strSQL

' set the record source for the form. It is the information for the
' most recently selected dog. The dog selected can be one of three
options
' that's why me.control(strcontrol).value is used
Me.RecordSource = "Select * from qrySelectDog WHERE DogID = " &
Me.Controls(strControl).Value

' Me.grpJumpHeight = DLookup("JumpHeightinInches",
"qrySelectDogsInEventEntry", _
"DogID=" & Me.cboSelectRegisteredName)

' go get the arm band number for the selected dog.
Me!lstArmBandNumber.RowSource = BuildABNListBox(Me!DogID.Value,
Me!txtEventID, Me)

' set the other selection combo boxes on the form so they all say the same
dog.
Me!cboSelectRegisteredName.Value = Me.Controls(strControl)
Me!cboSelectCallName.Value = Me.Controls(strControl)
Me!cboSelectRegistrationNumber.Value = Me.Controls(strControl)

Call RemoveItemsSelected

Me!cmdAddClass.SetFocus
<----------------------------------- 2115 happens on this line of code
Me!lstQuickEntry.Selected(0) = True

EnableControls Me, acHeader, False
Me!cmdCancel.Enabled = True
Me!cmdApply.Enabled = True

Application.Echo True, "ready"
End Function
 
R

Rick A

I've narrowed it down to this.

I have created a listbox with multi select set to none.

When I run the code below I receive the 2115 error on the setfocus.

For Each varItm In Me!lstJumpHeight.ItemsSelected
Me!lstJumpHeight.Selected(varItm) = False
Next varItm
Me!cmdAddClass.SetFocus - when the False line is executed the setfocus
line errors.

If I change the listbox to extended it works.

What have I missed?

--
Rick Allison

-------------------------------------------------------------------------------------------------------------------------

Rick A said:
I've done some research on 2115 errors cannot figure this out. In Access
2000, I've created form with a subform.

Here's the three pieces of code where I think the problem resides. The
2115 error happens after I click cboSelectRegistrationNumber, then
cmdAddClass, then cmdApply, then cboSelectRegistrationNumber again. The
key seems to be the cmdAddClass code. See below, I highlighted the line
of code where the program stops because of the 2115 error.

If I click cboSelectRegistrationNumber, then cmdApply, then the
cboSelectRegistrationNumber again I do not receive the error. The same
line of code is executed again with no issues.

I've tried removing the RunCommand acCmdSaveRecord, having read about this
but that does not fix the issue. There has to be something in the
cmdAddClass routine but I cannot find it. Does anyone have any ideas I
can try? By the way, this function - Call AddABNtoDatabase(Me!DogID,
Me!lstArmBandNumber) needs the subform record to be committed to the
database or it abends. If I can figure out the 2115 error I think I can
figure everything out.

Thanks,

Rick

****ONE****
Private Sub cmdApply_Click()
MsgBox Me!txtRegisteredName & " has been updated", vbOKOnly +
vbInformation, "Updated"
Me!lstArmBandNumber.RowSource = ""
Me!lstDogEntry.RowSource = ""
Me.RecordSource = ""
Me!txtClassesFor.Visible = False
Me!txtEntryFor.Visible = False
EnableControls Me, acHeader, True
Me!cboSelectRegisteredName.SetFocus
Me!cmdApply.Enabled = False
Me!cmdCancel.Enabled = False
Me!pgeEntryInformation.Visible = True
Me!tabEntry.Value = 0
EnableControls Me, acDetail, False
EnableControls Me!fsubUniversalGenericEntryDogEvent.Form, acDetail,
False
End Sub

****TWO****
Private Sub cmdAddClass_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim blnAddedClasses As Boolean

' Put in Entry Date - do this first to add the row to trelDogEvent
Me!fsubUniversalGenericEntryDogEvent.Form!txtEntryReceivedDate = Date
Me!fsubUniversalGenericEntryDogEvent.SetFocus
Me!fsubUniversalGenericEntryDogEvent.Form!txtEntryReceivedDate.SetFocus
RunCommand acCmdSaveRecord ' should save the information on the subform

blnAddedClasses = False
Application.Echo False, "Adding Classes..."
Set dbs = CurrentDb()
If Me!lstQuickEntry.ItemsSelected.Count > 0 Then
Set ctl = Me!lstQuickEntry
For Each varItm In ctl.ItemsSelected
strSQL = "SELECT tblTitleEvent.TitleEventDateID,
tblTitleEvent.TitleID, " & _
"qrySelectTitle.LevelID, qrySelectTitle.DivisionID, " & _
"qrySelectTitle.LevelName, qrySelectTitle.DivisionName " &
_
"FROM qrySelectTitle INNER JOIN tblTitleEvent ON " & _
"qrySelectTitle.TitleID = tblTitleEvent.TitleID " & _
"WHERE qrySelectTitle.LevelID=" & ctl.Column(0, varItm) & "
" & _
"AND qrySelectTitle.DivisionID=" & ctl.Column(1, varItm)
Set rst = dbs.OpenRecordset(strSQL)
With rst
If ValidJumpHeight(!LevelName, !DivisionName) Then
While Not .EOF
Call AddDogEntry(Me.Name, _
Me!DogID, _
!TitleID, _
!TitleEventDateID, _
Me!lstJumpHeight.Column(0))
.MoveNext
blnAddedClasses = True
Wend
End If
End With
Next varItm
Else
If Me!lstTitleList.ItemsSelected.Count > 0 Then
Set ctl = Me!lstTitleList
For Each varItm In ctl.ItemsSelected
strSQL = "Select LevelName, DivisionName " & _
"From qrySelectTitle " & _
"Where TitleID = " & ctl.Column(0, varItm)
Set rst = dbs.OpenRecordset(strSQL)
With rst

If ValidJumpHeight(!LevelName, !DivisionName) Then
' add this entry for the dog to the database
Call AddDogEntry(Me.Name, _
Me!DogID, _
ctl.Column(0, varItm), _
ctl.Column(1, varItm), _
Me!lstJumpHeight.Column(0))
blnAddedClasses = True
End If
End With
Next varItm
Else
MsgBox "Please Select a Quick Entry Item " & vbCrLf & vbCrLf & _
" or a Date and Title", vbOKOnly + vbInformation, "Missing
Information"
End If
End If
rst.Close
dbs.Close
Set rst = Nothing
Set dbs = Nothing

If blnAddedClasses Then
Me!lstArmBandNumber.RowSource = RemoveABNListBox(Me!lstArmBandNumber)
Me!lstArmBandNumber.RowSource = _
AddToABNListBox(, Me!lstArmBandNumber.RowSource,
Me!lstJumpHeight.Column(0))
Call AddABNtoDatabase(Me!DogID, Me!lstArmBandNumber)
Call DogDateLastEntered(Me!DogID, Me!txtOrganizationCD,
Me!txtApplicationTypeCD)
Call OwnerDateLastEntered(DLookup("OwnerID", "tblDog", "DogID=" &
Me!DogID), _
Me!txtOrganizationCD,
Me!txtApplicationTypeCD)
End If

Application.Echo True

Me!lstDogEntry.Requery

End Sub

****THREE****
Private Sub cboSelectRegistrationNumber_AfterUpdate()
Call AfterSelectionRoutine("cboSelectRegistrationNumber")
End Sub
Function AfterSelectionRoutine(strControl As String) As String
' this routine executes after a dog is selected.
Application.Echo False, "thinking...."

' turn the controls on for the detail section of the form,
' set focus, turn off the controls for the header section,
' enagle the cancel button and the apply button
EnableControls Me, acDetail, True

Me!txtClassesFor.Visible = True
Me!txtEntryFor.Visible = True

If Me!fsubUniversalGenericEntryDogEvent.SourceObject = "" Then
Me!fsubUniversalGenericEntryDogEvent.SourceObject =
"fsubUniversalGenericEntryDogEvent"
Select Case Me!txtOrganizationCD
Case "CKC"

Me!fsubUniversalGenericEntryDogEvent.Form!txtEntryReceivedDate.Format =
"dd/mm/yyyy"
Case "AKC"

Me!fsubUniversalGenericEntryDogEvent.Form!txtEntryReceivedDate.Format =
"mm/dd/yyyy"
End Select
End If

' finally enable the controls on the dog event subform
' EnableControls fsubUniversalGenericEntryDogEvent.Form, acDetail, True

' populate the event dates listbox one time after load
' this will speed up initial load of the form.
If Me!lstEventDates.RowSource = "" Then
strSQL = "SELECT EventDateID, " & _

"IIf(dLookup('OrganizationCD','qrySelectControlApplicationData')='CKC','#'
& EventDateDescription & ' ' &
Format(EventDate,'dddd'),Format(EventDate,'ddd mmm-dd-yyyy')) AS
FormatedEventDate, " & _
"EventDate " & _
"FROM qrySelectEventDate; "
Me!lstEventDates.RowSource = strSQL
' also populate title list listbox based on first row of the
' event dates listbox and after the first load of the event date
strSQL = "SELECT [TitleID], [TitleEventDateID], [Title], [EventDateID],
[LevelName], [DivisionName] " & _
"FROM qrytblTitleEvent WHERE EventDateID=" &
Me!lstEventDates.ItemData(0)
Me!lstTitleList.RowSource = strSQL
Me!lblTitlesFor.Caption = "Titles for " &
Format(Me!lstEventDates.Column(2, 0), "dddd dd-mmm-yyyy")

Me!lstJumpHeight.RowSource = "qrySelectJumpHeight"

Me!lstJumpHeightISC.RowSource = "qrySelectJumpHeightISC"

Me!lstQuickEntry.RowSource = "qrySelectQuickLinkList"
Me!txtEntryFor.Visible = True
Me!txtClassesFor.Visible = True
Me!lblTitlesFor.Visible = True
End If

' position on the first row of the event dates listbox
' Me.lstEventDates = Me.lstEventDates.ItemData(0)


' Set up the dog entry listbox based on what dog was selected
strSQL = "SELECT DogID, TitleEventDateID, EventID, " & _
"Format([EventDate],'ddd dd-mmm-yyyy') AS [Event Date], " & _
"EventDateDescription as [Trial Number], TitleAbbreviated as
[Title], " & _
"JumpHeightCD as [Jump Height] " & _
"FROM qrySelectDogEntry " & _
"WHERE DogID = " & Me.Controls(strControl).Value & " and " & _
"EventID = " & Me!txtEventID & " " & _
"ORDER BY EventDate, EventDateDescription, CatalogSortOrder"
Me!lstDogEntry.RowSource = strSQL

' set the record source for the form. It is the information for the
' most recently selected dog. The dog selected can be one of three
options
' that's why me.control(strcontrol).value is used
Me.RecordSource = "Select * from qrySelectDog WHERE DogID = " &
Me.Controls(strControl).Value

' Me.grpJumpHeight = DLookup("JumpHeightinInches",
"qrySelectDogsInEventEntry", _
"DogID=" & Me.cboSelectRegisteredName)

' go get the arm band number for the selected dog.
Me!lstArmBandNumber.RowSource = BuildABNListBox(Me!DogID.Value,
Me!txtEventID, Me)

' set the other selection combo boxes on the form so they all say the
same dog.
Me!cboSelectRegisteredName.Value = Me.Controls(strControl)
Me!cboSelectCallName.Value = Me.Controls(strControl)
Me!cboSelectRegistrationNumber.Value = Me.Controls(strControl)

Call RemoveItemsSelected

Me!cmdAddClass.SetFocus <----------------------------------- 2115
happens on this line of code
Me!lstQuickEntry.Selected(0) = True

EnableControls Me, acHeader, False
Me!cmdCancel.Enabled = True
Me!cmdApply.Enabled = True

Application.Echo True, "ready"
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top