A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Filtering a form with a combo box using left function



 
 
Thread Tools Display Modes
  #1  
Old March 10th, 2010, 03:56 PM posted to microsoft.public.access
jean
external usenet poster
 
Posts: 19
Default Filtering a form with a combo box using left function

Hi

I have a table named "TblData" containing 5 field

One field is named "IDProcedure" (text field)

This field contains information like "M-41-25" or "P-1000" or simply
"41-50"

I have a form with "TblData" as records source

As I want to filter the form, I create a combo box with 3 choices
"Manuals"; "Procedures" and "Process"

Now I have to put some code on the after update of the combo box
"ChoixCat" to filter the form

The only way I can manege it is using the first left character of the
field "IDProcedure"

So if the user select "Manuals", I want the filter to be applied to
all records starting with the lette "M"
if the user select "Process" I want the filter to be applied to all
records starting with the letter "P"
And finaly if the user select "Procedures" The filter should be
applied to all records starting with a number (from 0 to 9)

I have start with and if statement like

If [ChoixCat] = "Manuals" Then

Me.Filter = "left([IDProcedure], 1) = 'M'"
Me.FilterOn = True

End If

If [ChoixCat] = "Process" Then

Me.Filter = "left([IDProcedure], 1) = 'P'"
Me.FilterOn = True

End If

If [ChoixCat] = "Procedures" Then

Me.Filter = "left([IDProcedure], 1) =0"
Me.FilterOn = True

End If

I cannot find the right syntax for the last if statement. It should
filter all records where the IDProcedure start with any number
including 0

thanks for helping

  #2  
Old March 10th, 2010, 04:41 PM posted to microsoft.public.access
John Spencer
external usenet poster
 
Posts: 7,815
Default Filtering a form with a combo box using left function

Try using Like with a wildcard

Me.Filter = "[IDProcedure] LIKE '[0-9]*'"

You could use similar logic with your other filters
Me.Filter = "[IDProcedure] Like 'M*'"
Me.Filter = "[IDProcedure] Like 'P*'"

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

jean wrote:
Hi

I have a table named "TblData" containing 5 field

One field is named "IDProcedure" (text field)

This field contains information like "M-41-25" or "P-1000" or simply
"41-50"

I have a form with "TblData" as records source

As I want to filter the form, I create a combo box with 3 choices
"Manuals"; "Procedures" and "Process"

Now I have to put some code on the after update of the combo box
"ChoixCat" to filter the form

The only way I can manege it is using the first left character of the
field "IDProcedure"

So if the user select "Manuals", I want the filter to be applied to
all records starting with the lette "M"
if the user select "Process" I want the filter to be applied to all
records starting with the letter "P"
And finaly if the user select "Procedures" The filter should be
applied to all records starting with a number (from 0 to 9)

I have start with and if statement like

If [ChoixCat] = "Manuals" Then

Me.Filter = "left([IDProcedure], 1) = 'M'"
Me.FilterOn = True

End If

If [ChoixCat] = "Process" Then

Me.Filter = "left([IDProcedure], 1) = 'P'"
Me.FilterOn = True

End If

If [ChoixCat] = "Procedures" Then

Me.Filter = "left([IDProcedure], 1) =0"
Me.FilterOn = True

End If

I cannot find the right syntax for the last if statement. It should
filter all records where the IDProcedure start with any number
including 0

thanks for helping

  #3  
Old March 10th, 2010, 04:43 PM posted to microsoft.public.access
Kc-Mass
external usenet poster
 
Posts: 362
Default Filtering a form with a combo box using left function

Look at the "Like" operator in the help file.
"Like [1-9]"

Regards

Kevin


"jean" wrote in message
...
Hi

I have a table named "TblData" containing 5 field

One field is named "IDProcedure" (text field)

This field contains information like "M-41-25" or "P-1000" or simply
"41-50"

I have a form with "TblData" as records source

As I want to filter the form, I create a combo box with 3 choices
"Manuals"; "Procedures" and "Process"

Now I have to put some code on the after update of the combo box
"ChoixCat" to filter the form

The only way I can manege it is using the first left character of the
field "IDProcedure"

So if the user select "Manuals", I want the filter to be applied to
all records starting with the lette "M"
if the user select "Process" I want the filter to be applied to all
records starting with the letter "P"
And finaly if the user select "Procedures" The filter should be
applied to all records starting with a number (from 0 to 9)

I have start with and if statement like

If [ChoixCat] = "Manuals" Then

Me.Filter = "left([IDProcedure], 1) = 'M'"
Me.FilterOn = True

End If

If [ChoixCat] = "Process" Then

Me.Filter = "left([IDProcedure], 1) = 'P'"
Me.FilterOn = True

End If

If [ChoixCat] = "Procedures" Then

Me.Filter = "left([IDProcedure], 1) =0"
Me.FilterOn = True

End If

I cannot find the right syntax for the last if statement. It should
filter all records where the IDProcedure start with any number
including 0

thanks for helping



  #4  
Old March 10th, 2010, 04:48 PM posted to microsoft.public.access
ghetto_banjo
external usenet poster
 
Posts: 325
Default Filtering a form with a combo box using left function

try using the IsNumeric Function.

me.filter = "IsNumeric(Left(IDProcedure,1))


  #5  
Old March 17th, 2010, 01:37 PM posted to microsoft.public.access
joelgeraldine
external usenet poster
 
Posts: 201
Default Filtering a form with a combo box using left function

yytyyttrrrr

"jean" a écrit dans le message de groupe de
discussion :
...
Hi

I have a table named "TblData" containing 5 field

One field is named "IDProcedure" (text field)

This field contains information like "M-41-25" or "P-1000" or simply
"41-50"

I have a form with "TblData" as records source

As I want to filter the form, I create a combo box with 3 choices
"Manuals"; "Procedures" and "Process"

Now I have to put some code on the after update of the combo box
"ChoixCat" to filter the form

The only way I can manege it is using the first left character of the
field "IDProcedure"

So if the user select "Manuals", I want the filter to be applied to
all records starting with the lette "M"
if the user select "Process" I want the filter to be applied to all
records starting with the letter "P"
And finaly if the user select "Procedures" The filter should be
applied to all records starting with a number (from 0 to 9)

I have start with and if statement like

If [ChoixCat] = "Manuals" Then

Me.Filter = "left([IDProcedure], 1) = 'M'"
Me.FilterOn = True

End If

If [ChoixCat] = "Process" Then

Me.Filter = "left([IDProcedure], 1) = 'P'"
Me.FilterOn = True

End If

If [ChoixCat] = "Procedures" Then

Me.Filter = "left([IDProcedure], 1) =0"
Me.FilterOn = True

End If

I cannot find the right syntax for the last if statement. It should
filter all records where the IDProcedure start with any number
including 0

thanks for helping

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:18 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.