below here is my code for sql
but it has error.
please amend it for me and i will pose the points to you all.
error code is 3075
Dim strWhere As String
Dim strWhere1 As String
Dim strWhere2 As String
Dim strWhere3 As String
Dim strWhere5 As String
Dim strWhere6 As String
Dim strWhere7 As String
If Len(Trim$(pcuser.Text)) > 0 Then 'First field Query
strWhere = "WHERE name LIKE " & Chr$(34) & pcuser.Text & "*" & Chr$(34)
End If
If Len(Trim$(pcid.Text)) > 0 Then 'Second field Query
If Len(strWhere) = 0 Then
strWhere1 = "WHERE id LIKE " & Chr$(34) & pcid.Text & "*" & Chr$(34)
Else
strWhere1 = "AND id LIKE " & Chr$(34) & pcid.Text & "*" & Chr$(34)
End If
End If
If Len(Trim$(pcdept.Text)) > 0 Then 'third field Query
If Len(strWhere) = 0 Then
strWhere2 = "WHERE dept LIKE " & Chr$(34) & pcdept.Text & "*" & Chr$(34)
Else
strWhere2 = "AND dept LIKE " & Chr$(34) & pcdept.Text & "*" & Chr$(34)
End If
End If
If Len(Trim$(pcmonitor.Text))
> 0 Then 'Enam Field Query
If Len(strWhere) = 0 Then
strWhere3 = "WHERE monitor LIKE " & Chr$(34) & pcmonitor.Text & "*" & Chr$(34)
Else
strWhere3 = " AND monitor LIKE " & Chr$(34) & pcmonitor.Text & "*" & Chr$(34)
End If
End If
If Len(Trim$(pccpu.Text)) > 0 Then 'Tujuh field Query
If Len(strWhere) = 0 Then
strWhere4 = "WHERE cpu LIKE " & Chr$(34) & pccpu.Text & "*" & Chr$(34)
Else
strWhere4 = " AND cpu LIKE " & Chr$(34) & pccpu.Text & "*" & Chr$(34)
End If
End If
If Len(Trim$(pcsmonitor.Text)
) > 0 Then 'Tiga Belas Field Query
If Len(strWhere) = 0 Then
strWhere5 = "WHERE serialmoNITOR LIKE " & Chr$(34) & pcsmonitor.Text & "*" & Chr$(34)
Else
strWhere5 = " AND serialmoNITOR LIKE " & Chr$(34) & pcsmonitor.Text & "*" & Chr$(34)
End If
End If
If Len(Trim$(pcscpu.Text)) > 0 Then 'Empat Belas Field Query
If Len(strWhere) = 0 Then
strWhere6 = "WHERE serialCpu LIKE " & Chr$(34) & pcscpu.Text & "*" & Chr$(34)
Else
strWhere6 = " AND serialcpu LIKE " & Chr$(34) & pcscpu.Text & "*" & Chr$(34)
End If
End If
If Len(Trim$(pcuserkey.Text))
> 0 Then 'Dua puluh tujuh Field Query
If Len(strWhere) = 0 Then
strWhere7 = "WHERE USERKEY LIKE " & Chr$(34) & pcuserkey.Text & "*" & Chr$(34)
Else
strWhere7 = " AND USERKEY LIKE " & Chr$(34) & pcuserkey.Text & "*" & Chr$(34)
End If
End If
dataf.datapc.RecordSource = "SELECT * FROM PCREPORTDB " & strWhere & strWhere1 & strWhere2 _
& strWhere3 & strWhere4 & strWhere5 & strWhere6 & strWhere7 & "ORDER BY " & Text1.Text
dataf.datapc.Refresh
dataf.datapc.Recordset.Rec
ordCount