hey guys,
i'm trying to retrieve the text from a textbox, search for a substring within that text, and then replace it with another substring that is the result of a query.
for example i'm trying to replace: "the bear climbed up the @123" with "the bear climbed up the mountain"
i am now getting an "argument not optional" error
i'm not sure where to go from here....
here is my code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If (Me.txtSentence.Text <> ""
Then
Dim db As Database
Dim qdef As QueryDef
Dim rs As Recordset
Dim question As String
Dim priority As String
Dim varPriority As String
Dim sentence As String
Dim myPos As Integer
sentence = Me.txtSentence.Text
myPos = InStr(sentence, "@"
priority = Mid(sentence, myPos, 5)
varPriority = Mid(priority, 2, 4)
Set db = CurrentDb()
Set qdef=db.QueryDefs"qrybasInspectionResponsePrioritySelPrm"
qdef.Parameters("pPriority"
= varPriority
Set rs = qdef.OpenRecordset()
question = rs.FindFirst
Me.Report.txtSentence.Text = Replace(sentence, priority, question)
End If
End Sub
any help would be greatly appreciated!!!
thanks in advance!!
-mike
mikednova@hotmail.com
i'm trying to retrieve the text from a textbox, search for a substring within that text, and then replace it with another substring that is the result of a query.
for example i'm trying to replace: "the bear climbed up the @123" with "the bear climbed up the mountain"
i am now getting an "argument not optional" error
i'm not sure where to go from here....
here is my code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If (Me.txtSentence.Text <> ""
Dim db As Database
Dim qdef As QueryDef
Dim rs As Recordset
Dim question As String
Dim priority As String
Dim varPriority As String
Dim sentence As String
Dim myPos As Integer
sentence = Me.txtSentence.Text
myPos = InStr(sentence, "@"
priority = Mid(sentence, myPos, 5)
varPriority = Mid(priority, 2, 4)
Set db = CurrentDb()
Set qdef=db.QueryDefs"qrybasInspectionResponsePrioritySelPrm"
qdef.Parameters("pPriority"
Set rs = qdef.OpenRecordset()
question = rs.FindFirst
Me.Report.txtSentence.Text = Replace(sentence, priority, question)
End If
End Sub
any help would be greatly appreciated!!!
thanks in advance!!
-mike
mikednova@hotmail.com