D
David Wetmore
The following code works fine when executed as a double-click event. When I change it to
a click event I get run-time error 2115 when in BannerUpdate (last routine in the code
snippit). The text displays in the banner and I get the error.
comboQuads is a combo box which is populated through the not in list event.
What is happening, and how can I fix the problem?
Private Sub comboQuads_Click()
'Having selected a descriptor, make the link and add the text to the banner display.
Call MakeLinkRecord(rsProjects, comboQuads, rsQuadLinks, strQuadBanner)
Call BannerUpdate(txtQuadBanner, strQuadBanner)
End Sub 'comboQuads_Click
Private Sub MakeLinkRecord(ParentSet As Recordset, ChildBox As ComboBox, rsLinkSet As
Recordset, strBannerText As String)
'Builds a link with the child info from the the combobox, updates the banner box text
On Error GoTo LinkError
With rsLinkSet
.AddNew
!ParentKey = ParentSet!ProjectKey
!ChildKey = ChildBox.Column(0)
.Update
.MoveLast
End With
If strBannerText = "" Then
strBannerText = ChildBox.Column(1)
Else
strBannerText = strBannerText & vbCrLf & ChildBox.Column(1)
End If
NewLink:
Exit Sub
LinkError:
If (Err.Number = 3022) Then
MsgBox ("""" & ChildBox.Column(1) & """" & "is already part of this project.")
Resume NewLink
End If
End Sub 'MakeLinkRecord
Private Sub BannerUpdate(txtBanner As TextBox, strBannerText As String)
'Keep the banner boxes read-only
txtBanner.SetFocus
txtBanner.Locked = False
txtBanner.Text = strBannerText 'Run-time error 2115
txtBanner.Locked = True
End Sub 'BannerUpdate
a click event I get run-time error 2115 when in BannerUpdate (last routine in the code
snippit). The text displays in the banner and I get the error.
comboQuads is a combo box which is populated through the not in list event.
What is happening, and how can I fix the problem?
Private Sub comboQuads_Click()
'Having selected a descriptor, make the link and add the text to the banner display.
Call MakeLinkRecord(rsProjects, comboQuads, rsQuadLinks, strQuadBanner)
Call BannerUpdate(txtQuadBanner, strQuadBanner)
End Sub 'comboQuads_Click
Private Sub MakeLinkRecord(ParentSet As Recordset, ChildBox As ComboBox, rsLinkSet As
Recordset, strBannerText As String)
'Builds a link with the child info from the the combobox, updates the banner box text
On Error GoTo LinkError
With rsLinkSet
.AddNew
!ParentKey = ParentSet!ProjectKey
!ChildKey = ChildBox.Column(0)
.Update
.MoveLast
End With
If strBannerText = "" Then
strBannerText = ChildBox.Column(1)
Else
strBannerText = strBannerText & vbCrLf & ChildBox.Column(1)
End If
NewLink:
Exit Sub
LinkError:
If (Err.Number = 3022) Then
MsgBox ("""" & ChildBox.Column(1) & """" & "is already part of this project.")
Resume NewLink
End If
End Sub 'MakeLinkRecord
Private Sub BannerUpdate(txtBanner As TextBox, strBannerText As String)
'Keep the banner boxes read-only
txtBanner.SetFocus
txtBanner.Locked = False
txtBanner.Text = strBannerText 'Run-time error 2115
txtBanner.Locked = True
End Sub 'BannerUpdate