I have created a "search" facility on one of my forms. The main form is called frmIfTFertAppln and has an unbound text box called Search which has the following code
Search2 is also unbound.
The subform is called frmIfFertAppln and is a single form and is populated using the following code.
I want the search to work in two ways. I work in agriculture and so on this form I search by field name (as in farmers field not access field) so if the field name is Bratch I type that in, the record for Bratch comes up and this works how I want it to.
I also want to be able to search for "fields beginning with.." . The subform is a single form so if I type in "b" into the search then I get one of the fields beginning with B and I move around them using the next or previous buttons but I want the first record to show to be the first in the alphabet so Back field, then Bee Field then Bratch. At the moment I am getting all the records and if I navigate through the records they are in alphabetical order but the record that the form opens on might be "Bee Field" or "Bratch" and I want it to be "Back Field".
I have set the properties of the temporary table tblTEMPIfFertAppln to order by FieldName.
I hope that makes sense and I wonder if anyone has any ideas as to how I might be able to achieve this.
Thanks in advance
Code:
Private Sub Search_Change()
Dim vSearchString As String
vSearchString = Search.Text
Search2.Value = vSearchString
Me.frmIfFertAppln.Requery
End Sub
Search2 is also unbound.
The subform is called frmIfFertAppln and is a single form and is populated using the following code.
Code:
SELECT tblTEMPIfFertAppln.FieldCode, tblTEMPIfFertAppln.AccountName, tblTEMPIfFertAppln.FarmAccountNumber, tblTEMPIfFertAppln.FieldName, tblTEMPIfFertAppln.FieldComments, tblTEMPIfFertAppln.[SubFarm/FieldGroup], tblTEMPIfFertAppln.SoilTexture, tblTEMPIfFertAppln.NVZStatement, tblTEMPIfFertAppln.NoLongerCropped, tblTEMPIfFertAppln.DateOfAnalysis, tblTEMPIfFertAppln.PIndex, tblTEMPIfFertAppln.KIndex, tblTEMPIfFertAppln.MgIndex, tblTEMPIfFertAppln.pH, RemovePunc([tblTEMPIfFertAppln].[FieldName]) AS Expr1
FROM tblTEMPIfFertAppln
WHERE (((RemovePunc([tblTEMPIfFertAppln].[FieldName])) Like [Forms]![frmIfTFertAppln]![Search2] & "*"))
ORDER BY tblTEMPIfFertAppln.FieldName;
I want the search to work in two ways. I work in agriculture and so on this form I search by field name (as in farmers field not access field) so if the field name is Bratch I type that in, the record for Bratch comes up and this works how I want it to.
I also want to be able to search for "fields beginning with.." . The subform is a single form so if I type in "b" into the search then I get one of the fields beginning with B and I move around them using the next or previous buttons but I want the first record to show to be the first in the alphabet so Back field, then Bee Field then Bratch. At the moment I am getting all the records and if I navigate through the records they are in alphabetical order but the record that the form opens on might be "Bee Field" or "Bratch" and I want it to be "Back Field".
I have set the properties of the temporary table tblTEMPIfFertAppln to order by FieldName.
I hope that makes sense and I wonder if anyone has any ideas as to how I might be able to achieve this.
Thanks in advance