Private Sub cmdsearch_Click()
Dim DB As New ADODB
Set DB = CurrentProject.Connection
Dim strtj As String
strtj = " SELECT tblsupplier.SupplierID, tblsupplier.SupplierName, tblsupplier.Address, tblsupplier.Postal, tblsupplier.Tel, tblsupplier.Fax, tblsupplier.BP, tblsupplier.Email, tblsupplier.Contact, tblsupplier.message INTO tbltemp FROM tblsupplier"
strtj = strtj & "where SupplierID like '*" & txt¹©Ó¦ÉÌ_ID & "*' "
MsgBox strtj
Dim cmd As Command
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdText
.CommandText = strtj '
End With
Dim rs As Recordset
Set rs = New ADODB.Recordset
rs.ActiveConnection = CurrentProject.Connection
rs.Open "tbltemp", , adOpenKeyset, adLockBatchOptimistic, adCmdTable
Set rs = Nothing
DoCmd.SelectObject acTable, "tbltemp", True
DoCmd.OpenTable "tbltemp", acViewNormal, acReadOnly
Set DB = Nothing
'frmsupplier_sub.Requery
End Sub
THE QUESTION IS :
USE THE UPPER CODES, I SHOULD GET THE TABLE CALLED tbltemp WHICH HAVE THE DATA THAT SUIT FOR THE CONDITION, BUT THE RESULT IS NOT AS I THINK.
IF I DELETE THE BELOW SENTENCE "strtj = strtj & "where SupplierID like '*" & txt¹©Ó¦ÉÌ_ID & "*' "
"
THE RESULT IS RIGHT.
BUT I CAN NOT GIVE CONDITION TO THIS OPERATION.
I WANT TO HOW TO DEAL WITH IT.
THANK YOU.
Dim DB As New ADODB
Set DB = CurrentProject.Connection
Dim strtj As String
strtj = " SELECT tblsupplier.SupplierID, tblsupplier.SupplierName, tblsupplier.Address, tblsupplier.Postal, tblsupplier.Tel, tblsupplier.Fax, tblsupplier.BP, tblsupplier.Email, tblsupplier.Contact, tblsupplier.message INTO tbltemp FROM tblsupplier"
strtj = strtj & "where SupplierID like '*" & txt¹©Ó¦ÉÌ_ID & "*' "
MsgBox strtj
Dim cmd As Command
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdText
.CommandText = strtj '
End With
Dim rs As Recordset
Set rs = New ADODB.Recordset
rs.ActiveConnection = CurrentProject.Connection
rs.Open "tbltemp", , adOpenKeyset, adLockBatchOptimistic, adCmdTable
Set rs = Nothing
DoCmd.SelectObject acTable, "tbltemp", True
DoCmd.OpenTable "tbltemp", acViewNormal, acReadOnly
Set DB = Nothing
'frmsupplier_sub.Requery
End Sub
THE QUESTION IS :
USE THE UPPER CODES, I SHOULD GET THE TABLE CALLED tbltemp WHICH HAVE THE DATA THAT SUIT FOR THE CONDITION, BUT THE RESULT IS NOT AS I THINK.
IF I DELETE THE BELOW SENTENCE "strtj = strtj & "where SupplierID like '*" & txt¹©Ó¦ÉÌ_ID & "*' "
"
THE RESULT IS RIGHT.
BUT I CAN NOT GIVE CONDITION TO THIS OPERATION.
I WANT TO HOW TO DEAL WITH IT.
THANK YOU.