Click, Double-Click and Run Time Error 2115

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
 
J

J_Goddard via AccessMonster.com

Try replacing the

Call BannerUpdate(txtQuadBanner, strQuadBanner)

line with

txtquadbanner = strquadbanner

You don't need to go through the setfocus and lock/unlock process to change
the value of a text box. The locked property is usually only used to prevent
the user from changing the value directly by typing in the box - it can be
changed in code without unlocking it.

Does this help?

John
 

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