S
Steve
To facilitate form data entry, I want users to be able to click on items
within a list box and have that text be inserted into a specific area of a
text box. I have adapted a code to highlight "<>" with in the text box to
serve as the insertion target. For example, the text box reads, "The customer
ordered a <> basket". The list box choices are "small", "medium", and
"large". I would like the user to be able to click one of these options and
have that text inserted into the string at the "<>" marker: "The customer
ordered a large basket". Any help would be greatly appreciated. Thanks.
Option Compare Database
Private Sub Form_Load()
Dim ctlTextToSearch As Control
Set ctlTextToSearch = Forms!Form1!Textbox1
' SetFocus to text box.
ctlTextToSearch.SetFocus
ctlTextToSearch.Text = "The customer ordered a <> basket"
Set ctlTextToSearch = Nothing
End Sub
Public Sub Find_Click()
Dim strSearch As String
Dim intWhere As Integer
Dim ctlTextToSearch As Control
' find the first "<>".
With Me!Textbox1
strSearch = "<>"
' Find string in text.
intWhere = InStr(.Value, strSearch)
If intWhere Then
'If found.
.SetFocus
.SelStart = intWhere - 1
.SelLength = Len(strSearch)
Else
' Notify user.
MsgBox "String not found."
End If
End With
End Sub
within a list box and have that text be inserted into a specific area of a
text box. I have adapted a code to highlight "<>" with in the text box to
serve as the insertion target. For example, the text box reads, "The customer
ordered a <> basket". The list box choices are "small", "medium", and
"large". I would like the user to be able to click one of these options and
have that text inserted into the string at the "<>" marker: "The customer
ordered a large basket". Any help would be greatly appreciated. Thanks.
Option Compare Database
Private Sub Form_Load()
Dim ctlTextToSearch As Control
Set ctlTextToSearch = Forms!Form1!Textbox1
' SetFocus to text box.
ctlTextToSearch.SetFocus
ctlTextToSearch.Text = "The customer ordered a <> basket"
Set ctlTextToSearch = Nothing
End Sub
Public Sub Find_Click()
Dim strSearch As String
Dim intWhere As Integer
Dim ctlTextToSearch As Control
' find the first "<>".
With Me!Textbox1
strSearch = "<>"
' Find string in text.
intWhere = InStr(.Value, strSearch)
If intWhere Then
'If found.
.SetFocus
.SelStart = intWhere - 1
.SelLength = Len(strSearch)
Else
' Notify user.
MsgBox "String not found."
End If
End With
End Sub