I have been trying to amend a "search" facility that I have created on one of my forms.
I would like to be able to search by "like" or "begins with". On the main form I have an option group called OptSearch and value 1 is like and value 2 is begins with. The main form is called frmIfTCropping.
The subform is called frmIfCropping and is a single form and is populated using the following code.
I was hoping to put an iif statement into this code or add to the WHERE statement so that if Optsearch is 1 then the Like "*" & [Forms]![frmIfTCropping]![Search2] & "*" is used whereas if Optsearch is 2 the like statement loses the 1st "*" to become Like [Forms]![frmIfTCropping]![Search2] & "*" but I am stumped.
Can anyone give some suggestions as to how I achieve this?
Thank you in advance for any input
Neil
I would like to be able to search by "like" or "begins with". On the main form I have an option group called OptSearch and value 1 is like and value 2 is begins with. The main form is called frmIfTCropping.
The subform is called frmIfCropping and is a single form and is populated using the following code.
Code:
SELECT tblTEMPIfCropping.FarmAccountNumber, tblTEMPIfCropping.AccountName, tblTEMPIfCropping.FieldName, tblTEMPIfCropping.FieldCode, tblTEMPIfCropping.[SubFarm/FieldGroup], tblTEMPIfCropping.FieldComments, tblTEMPIfCropping.FieldOrder, tblTEMPIfCropping.NoLongerCropped, RemovePunc([tblTEMPIfCropping].[FieldName]) AS Expr1
FROM tblTEMPIfCropping
WHERE (((RemovePunc([tblTEMPIfCropping].[FieldName])) Like "*" & [Forms]![frmIfTCropping]![Search2] & "*"))
ORDER BY tblTEMPIfCropping.FieldName;
I was hoping to put an iif statement into this code or add to the WHERE statement so that if Optsearch is 1 then the Like "*" & [Forms]![frmIfTCropping]![Search2] & "*" is used whereas if Optsearch is 2 the like statement loses the 1st "*" to become Like [Forms]![frmIfTCropping]![Search2] & "*" but I am stumped.
Can anyone give some suggestions as to how I achieve this?
Thank you in advance for any input
Neil