If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
filter words
In my form i have text box 'Filter' and command button 'Find'.
If i type in my text box 'Filter' 1 or more letters and click on 'Find' button it will find records in my form. but it also filtering inside word. I will need to able filter only begining of each word. If i have in my field 'Name' column 3 words it should filter only begining of each words. Here is my code: Set rs = Me.Recordset.Clone Me.FilterOn = True Me.Form.Filter = "[Name] like '*' + '" & Me![Text96] & "' + '*'" =============================================== Please help me. Thank you |
#2
|
|||
|
|||
filter words
Me.Form.Filter = "Left([Name], Len(Me.Text96)) = '" & Me![Text96] & "'" Me.FilterOn = True "GGill" wrote: In my form i have text box 'Filter' and command button 'Find'. If i type in my text box 'Filter' 1 or more letters and click on 'Find' button it will find records in my form. but it also filtering inside word. I will need to able filter only begining of each word. If i have in my field 'Name' column 3 words it should filter only begining of each words. Here is my code: Set rs = Me.Recordset.Clone Me.FilterOn = True Me.Form.Filter = "[Name] like '*' + '" & Me![Text96] & "' + '*'" =============================================== Please help me. Thank you |
#3
|
|||
|
|||
filter words
Sorry, take the Form out.
Instead of Me.Form.Filter Use Me.Filter "GGill" wrote: In my form i have text box 'Filter' and command button 'Find'. If i type in my text box 'Filter' 1 or more letters and click on 'Find' button it will find records in my form. but it also filtering inside word. I will need to able filter only begining of each word. If i have in my field 'Name' column 3 words it should filter only begining of each words. Here is my code: Set rs = Me.Recordset.Clone Me.FilterOn = True Me.Form.Filter = "[Name] like '*' + '" & Me![Text96] & "' + '*'" =============================================== Please help me. Thank you |
#4
|
|||
|
|||
filter words
I have message error, i think problem with this 'Len(Me.Text96))'
May be i need declare Len, i am not sure, but this code is not working "Klatuu" wrote: Sorry, take the Form out. Instead of Me.Form.Filter Use Me.Filter "GGill" wrote: In my form i have text box 'Filter' and command button 'Find'. If i type in my text box 'Filter' 1 or more letters and click on 'Find' button it will find records in my form. but it also filtering inside word. I will need to able filter only begining of each word. If i have in my field 'Name' column 3 words it should filter only begining of each words. Here is my code: Set rs = Me.Recordset.Clone Me.FilterOn = True Me.Form.Filter = "[Name] like '*' + '" & Me![Text96] & "' + '*'" =============================================== Please help me. Thank you |
#5
|
|||
|
|||
filter words
No, Len does not need to declared. It is a VBA function.
What error are you getting? Also, the names I used may not be the correct names. Is Text96 the name of the control on your form? Is Name the name of the field in the form's record source? Using Name as a name is not good. It is an Access Reserved workd and can be a problem. No reserved words should be used in names (Name, Date, Year, etc.) "GGill" wrote: I have message error, i think problem with this 'Len(Me.Text96))' May be i need declare Len, i am not sure, but this code is not working "Klatuu" wrote: Sorry, take the Form out. Instead of Me.Form.Filter Use Me.Filter "GGill" wrote: In my form i have text box 'Filter' and command button 'Find'. If i type in my text box 'Filter' 1 or more letters and click on 'Find' button it will find records in my form. but it also filtering inside word. I will need to able filter only begining of each word. If i have in my field 'Name' column 3 words it should filter only begining of each words. Here is my code: Set rs = Me.Recordset.Clone Me.FilterOn = True Me.Form.Filter = "[Name] like '*' + '" & Me![Text96] & "' + '*'" =============================================== Please help me. Thank you |
#6
|
|||
|
|||
filter words
Actually the Name in my form call 'FullNm', it is record source.
Text96 is unbound text box, where i type any thing to filter. When i click on command button to filter it will pop-up small window 'Enter parameter value me.Text96', if i enter parameter the code works, but if i don't enter, then i have messaage error 'You canceled the previos operation'. Also if i do filter and i don't have any records, then form will be blank. where should i add to my code (MsgBox "No Records"). Thank you so much for helping. "Klatuu" wrote: No, Len does not need to declared. It is a VBA function. What error are you getting? Also, the names I used may not be the correct names. Is Text96 the name of the control on your form? Is Name the name of the field in the form's record source? Using Name as a name is not good. It is an Access Reserved workd and can be a problem. No reserved words should be used in names (Name, Date, Year, etc.) "GGill" wrote: I have message error, i think problem with this 'Len(Me.Text96))' May be i need declare Len, i am not sure, but this code is not working "Klatuu" wrote: Sorry, take the Form out. Instead of Me.Form.Filter Use Me.Filter "GGill" wrote: In my form i have text box 'Filter' and command button 'Find'. If i type in my text box 'Filter' 1 or more letters and click on 'Find' button it will find records in my form. but it also filtering inside word. I will need to able filter only begining of each word. If i have in my field 'Name' column 3 words it should filter only begining of each words. Here is my code: Set rs = Me.Recordset.Clone Me.FilterOn = True Me.Form.Filter = "[Name] like '*' + '" & Me![Text96] & "' + '*'" =============================================== Please help me. Thank you |
#7
|
|||
|
|||
filter words
You should refer to the control in the criteria for the field you are
filtering on in your query. The query does not understand Me. Me only works in the current form. It should be entered as: Forms!FullNm!Text96 If you want to present a message saying there are no matching records, you will have to use a DCount function to determine if there are matching records. You can use the query you are using to return records in the DCount: If DCount("*", "MyQueryName") = 0 Then MsgBox "No Matching Records" Else 'Do whatever you are doing now to return the records End If "GGill" wrote: Actually the Name in my form call 'FullNm', it is record source. Text96 is unbound text box, where i type any thing to filter. When i click on command button to filter it will pop-up small window 'Enter parameter value me.Text96', if i enter parameter the code works, but if i don't enter, then i have messaage error 'You canceled the previos operation'. Also if i do filter and i don't have any records, then form will be blank. where should i add to my code (MsgBox "No Records"). Thank you so much for helping. "Klatuu" wrote: No, Len does not need to declared. It is a VBA function. What error are you getting? Also, the names I used may not be the correct names. Is Text96 the name of the control on your form? Is Name the name of the field in the form's record source? Using Name as a name is not good. It is an Access Reserved workd and can be a problem. No reserved words should be used in names (Name, Date, Year, etc.) "GGill" wrote: I have message error, i think problem with this 'Len(Me.Text96))' May be i need declare Len, i am not sure, but this code is not working "Klatuu" wrote: Sorry, take the Form out. Instead of Me.Form.Filter Use Me.Filter "GGill" wrote: In my form i have text box 'Filter' and command button 'Find'. If i type in my text box 'Filter' 1 or more letters and click on 'Find' button it will find records in my form. but it also filtering inside word. I will need to able filter only begining of each word. If i have in my field 'Name' column 3 words it should filter only begining of each words. Here is my code: Set rs = Me.Recordset.Clone Me.FilterOn = True Me.Form.Filter = "[Name] like '*' + '" & Me![Text96] & "' + '*'" =============================================== Please help me. Thank you |
#8
|
|||
|
|||
filter words
FullNm is control sourse in my text box Nm,Text96 is unbound text box name,
control source in Text96 is nothig. Instead of Me.Text96, what should i us in my code. "Klatuu" wrote: You should refer to the control in the criteria for the field you are filtering on in your query. The query does not understand Me. Me only works in the current form. It should be entered as: Forms!FullNm!Text96 If you want to present a message saying there are no matching records, you will have to use a DCount function to determine if there are matching records. You can use the query you are using to return records in the DCount: If DCount("*", "MyQueryName") = 0 Then MsgBox "No Matching Records" Else 'Do whatever you are doing now to return the records End If "GGill" wrote: Actually the Name in my form call 'FullNm', it is record source. Text96 is unbound text box, where i type any thing to filter. When i click on command button to filter it will pop-up small window 'Enter parameter value me.Text96', if i enter parameter the code works, but if i don't enter, then i have messaage error 'You canceled the previos operation'. Also if i do filter and i don't have any records, then form will be blank. where should i add to my code (MsgBox "No Records"). Thank you so much for helping. "Klatuu" wrote: No, Len does not need to declared. It is a VBA function. What error are you getting? Also, the names I used may not be the correct names. Is Text96 the name of the control on your form? Is Name the name of the field in the form's record source? Using Name as a name is not good. It is an Access Reserved workd and can be a problem. No reserved words should be used in names (Name, Date, Year, etc.) "GGill" wrote: I have message error, i think problem with this 'Len(Me.Text96))' May be i need declare Len, i am not sure, but this code is not working "Klatuu" wrote: Sorry, take the Form out. Instead of Me.Form.Filter Use Me.Filter "GGill" wrote: In my form i have text box 'Filter' and command button 'Find'. If i type in my text box 'Filter' 1 or more letters and click on 'Find' button it will find records in my form. but it also filtering inside word. I will need to able filter only begining of each word. If i have in my field 'Name' column 3 words it should filter only begining of each words. Here is my code: Set rs = Me.Recordset.Clone Me.FilterOn = True Me.Form.Filter = "[Name] like '*' + '" & Me![Text96] & "' + '*'" =============================================== Please help me. Thank you |
#9
|
|||
|
|||
filter words
In your previous post, you said FullNm is the name of the form.
I'm getting really confused here. If Text96 is a unbound text box and you want to search on the value in that text box, the syntax is Forms!NameOfForm!Text96 "GGill" wrote: FullNm is control sourse in my text box Nm,Text96 is unbound text box name, control source in Text96 is nothig. Instead of Me.Text96, what should i us in my code. "Klatuu" wrote: You should refer to the control in the criteria for the field you are filtering on in your query. The query does not understand Me. Me only works in the current form. It should be entered as: Forms!FullNm!Text96 If you want to present a message saying there are no matching records, you will have to use a DCount function to determine if there are matching records. You can use the query you are using to return records in the DCount: If DCount("*", "MyQueryName") = 0 Then MsgBox "No Matching Records" Else 'Do whatever you are doing now to return the records End If "GGill" wrote: Actually the Name in my form call 'FullNm', it is record source. Text96 is unbound text box, where i type any thing to filter. When i click on command button to filter it will pop-up small window 'Enter parameter value me.Text96', if i enter parameter the code works, but if i don't enter, then i have messaage error 'You canceled the previos operation'. Also if i do filter and i don't have any records, then form will be blank. where should i add to my code (MsgBox "No Records"). Thank you so much for helping. "Klatuu" wrote: No, Len does not need to declared. It is a VBA function. What error are you getting? Also, the names I used may not be the correct names. Is Text96 the name of the control on your form? Is Name the name of the field in the form's record source? Using Name as a name is not good. It is an Access Reserved workd and can be a problem. No reserved words should be used in names (Name, Date, Year, etc.) "GGill" wrote: I have message error, i think problem with this 'Len(Me.Text96))' May be i need declare Len, i am not sure, but this code is not working "Klatuu" wrote: Sorry, take the Form out. Instead of Me.Form.Filter Use Me.Filter "GGill" wrote: In my form i have text box 'Filter' and command button 'Find'. If i type in my text box 'Filter' 1 or more letters and click on 'Find' button it will find records in my form. but it also filtering inside word. I will need to able filter only begining of each word. If i have in my field 'Name' column 3 words it should filter only begining of each words. Here is my code: Set rs = Me.Recordset.Clone Me.FilterOn = True Me.Form.Filter = "[Name] like '*' + '" & Me![Text96] & "' + '*'" =============================================== Please help me. Thank you |
Thread Tools | |
Display Modes | |
|
|