|
-
May 29th, 2000, 06:07 AM
#1
Thread Starter
Hyperactive Member
Woooooooo Hoooooooooooooooooooooooo
****************** F I N A L L Y *******************
Ok, here is the scoop!
It was just as simple as leaving a space before and after the like statement. I must admit,... I don't have a formal VB education, and it's trial and error for me a lot of the time. Syntax blues! Maybe this is true for a lot of folks also.
The Like statement was saved to a variable(dbLike) as " like "
It seems that the space before and after like made the difference. Wow, 5 hours to figure this out. LOL to me.
Here is the code:
Code:
Dim SearchField As String
Dim SearchString As String
Dim dbLike As String
Dim Sq As String
Private Sub cmdCancel_Click()
Me.Hide
End Sub
Private Sub cmdFindNext_Click()
SearchString = "'*" & txtFind & "*'"
' This was the source of a major headache here:
frmMain.Data1.Recordset.FindNext SearchField & dbLike & SearchString
' dbLike contains the like statement. The big deal is the
' space before and after like. Tee - dee - us!!!
MsgBox frmMain.Data1.Recordset.Fields(SearchField)
End Sub
Private Sub Form_Load()
' Here it is again (Note: space before and after like)
dbLike = " like "
End Sub
' The rest of this is really not a player, just passing
' variables, and selecting which field the user wants to
' search
Private Sub optField_Click(Index As Integer)
If optField(0).Value = True Then
txtFind.Width = 3375
SearchField = "question"
ElseIf optField(1).Value = True Then
txtFind.Width = 3375
SearchField = "answer"
ElseIf optField(2).Value = True Then
txtFind.Width = 1335
SearchField = "reference"
ElseIf optField(3).Value = True Then
txtFind.Width = 1335
SearchField = "date"
End If
End Sub
The quotes really weren't an issue at all. The real issue again was the like statement. I guess the machine was looking at my command and read it like this: "fieldlike'*txtwhatever*'" which is jibberish I will admit.
So, when I formatted the like statement with a space, it must have read it like this instead:
"field like '*txtwhatever*'" which is more logical. Gosh, I have a love-hate relationship with programming. Very time consuming.
Well, thanks to this forum, I will eventually complete my application. Thanks for your help Megatron.
Sal
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|