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
|
|||
|
|||
Case statement Problem
I am having trouble with this code can anyone help.
I have the follwing case statement that checks the value of the combo box, and based on that it will select which report to print, but I can not get it to work Select Case ReportPrint Case "Me![Combo28].column(1) = Like'B*'" stDocName = "Productsreport1" Case "Me![Combo28].column(1) = 'Like'C*''" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected Thanks in advance |
#2
|
|||
|
|||
Case statement Problem
hi Tony
"Me![Combo28].column(1) = Like'B*'" -- left(Me![Combo28].column(1),1) = "B" "Me![Combo28].column(1) = 'Like'C*''" -- left(Me![Combo28].column(1),1) = "C" Warm Regards, Crystal remote programming and training Access Basics 8-part free tutorial that covers essentials in Access http://www.AccessMVP.com/strive4peace * (: have an awesome day * tony Jacobs wrote: I am having trouble with this code can anyone help. I have the follwing case statement that checks the value of the combo box, and based on that it will select which report to print, but I can not get it to work Select Case ReportPrint Case "Me![Combo28].column(1) = Like'B*'" stDocName = "Productsreport1" Case "Me![Combo28].column(1) = 'Like'C*''" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected Thanks in advance |
#3
|
|||
|
|||
Case statement Problem
Select Case Left(Me.Combo28 & "",1)
Case "B" stDocName = "Productsreport1" Case "C" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected '================================================= === John Spencer Access MVP 2002-2005, 2007-2008 The Hilltop Institute University of Maryland Baltimore County '================================================= === strive4peace wrote: hi Tony "Me![Combo28].column(1) = Like'B*'" -- left(Me![Combo28].column(1),1) = "B" "Me![Combo28].column(1) = 'Like'C*''" -- left(Me![Combo28].column(1),1) = "C" Warm Regards, Crystal remote programming and training Access Basics 8-part free tutorial that covers essentials in Access http://www.AccessMVP.com/strive4peace * (: have an awesome day * tony Jacobs wrote: I am having trouble with this code can anyone help. I have the follwing case statement that checks the value of the combo box, and based on that it will select which report to print, but I can not get it to work Select Case ReportPrint Case "Me![Combo28].column(1) = Like'B*'" stDocName = "Productsreport1" Case "Me![Combo28].column(1) = 'Like'C*''" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected Thanks in advance |
#4
|
|||
|
|||
Case statement Problem
Sorry John; I did not work ! Any other ideas?
"John Spencer" wrote in message ... Select Case Left(Me.Combo28 & "",1) Case "B" stDocName = "Productsreport1" Case "C" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected '================================================= === John Spencer Access MVP 2002-2005, 2007-2008 The Hilltop Institute University of Maryland Baltimore County '================================================= === strive4peace wrote: hi Tony "Me![Combo28].column(1) = Like'B*'" -- left(Me![Combo28].column(1),1) = "B" "Me![Combo28].column(1) = 'Like'C*''" -- left(Me![Combo28].column(1),1) = "C" Warm Regards, Crystal remote programming and training Access Basics 8-part free tutorial that covers essentials in Access http://www.AccessMVP.com/strive4peace * (: have an awesome day * tony Jacobs wrote: I am having trouble with this code can anyone help. I have the follwing case statement that checks the value of the combo box, and based on that it will select which report to print, but I can not get it to work Select Case ReportPrint Case "Me![Combo28].column(1) = Like'B*'" stDocName = "Productsreport1" Case "Me![Combo28].column(1) = 'Like'C*''" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected Thanks in advance |
#5
|
|||
|
|||
Case statement Problem
Given you were trying to use Column(1) in your first example, try
Select Case Left(Me.Combo28.Column(1) & "", 1) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "tony Jacobs" wrote in message ... Sorry John; I did not work ! Any other ideas? "John Spencer" wrote in message ... Select Case Left(Me.Combo28 & "",1) Case "B" stDocName = "Productsreport1" Case "C" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected '================================================= === John Spencer Access MVP 2002-2005, 2007-2008 The Hilltop Institute University of Maryland Baltimore County '================================================= === strive4peace wrote: hi Tony "Me![Combo28].column(1) = Like'B*'" -- left(Me![Combo28].column(1),1) = "B" "Me![Combo28].column(1) = 'Like'C*''" -- left(Me![Combo28].column(1),1) = "C" Warm Regards, Crystal remote programming and training Access Basics 8-part free tutorial that covers essentials in Access http://www.AccessMVP.com/strive4peace * (: have an awesome day * tony Jacobs wrote: I am having trouble with this code can anyone help. I have the follwing case statement that checks the value of the combo box, and based on that it will select which report to print, but I can not get it to work Select Case ReportPrint Case "Me![Combo28].column(1) = Like'B*'" stDocName = "Productsreport1" Case "Me![Combo28].column(1) = 'Like'C*''" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected Thanks in advance |
#6
|
|||
|
|||
Case statement Problem
Doug;
No luck. No Errors but no results. Thanks for your time "Douglas J. Steele" wrote in message ... Given you were trying to use Column(1) in your first example, try Select Case Left(Me.Combo28.Column(1) & "", 1) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "tony Jacobs" wrote in message ... Sorry John; I did not work ! Any other ideas? "John Spencer" wrote in message ... Select Case Left(Me.Combo28 & "",1) Case "B" stDocName = "Productsreport1" Case "C" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected '================================================= === John Spencer Access MVP 2002-2005, 2007-2008 The Hilltop Institute University of Maryland Baltimore County '================================================= === strive4peace wrote: hi Tony "Me![Combo28].column(1) = Like'B*'" -- left(Me![Combo28].column(1),1) = "B" "Me![Combo28].column(1) = 'Like'C*''" -- left(Me![Combo28].column(1),1) = "C" Warm Regards, Crystal remote programming and training Access Basics 8-part free tutorial that covers essentials in Access http://www.AccessMVP.com/strive4peace * (: have an awesome day * tony Jacobs wrote: I am having trouble with this code can anyone help. I have the follwing case statement that checks the value of the combo box, and based on that it will select which report to print, but I can not get it to work Select Case ReportPrint Case "Me![Combo28].column(1) = Like'B*'" stDocName = "Productsreport1" Case "Me![Combo28].column(1) = 'Like'C*''" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected Thanks in advance |
#7
|
|||
|
|||
Case statement Problem
I would suggest you put a breakpoint at the beginning of your case stmt and
step thru the code, checking values-- if the code picks the correct report name, then the problem is in your DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected statement. Damon "tony Jacobs" wrote in message ... Doug; No luck. No Errors but no results. Thanks for your time "Douglas J. Steele" wrote in message ... Given you were trying to use Column(1) in your first example, try Select Case Left(Me.Combo28.Column(1) & "", 1) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "tony Jacobs" wrote in message ... Sorry John; I did not work ! Any other ideas? "John Spencer" wrote in message ... Select Case Left(Me.Combo28 & "",1) Case "B" stDocName = "Productsreport1" Case "C" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected '================================================= === John Spencer Access MVP 2002-2005, 2007-2008 The Hilltop Institute University of Maryland Baltimore County '================================================= === strive4peace wrote: hi Tony "Me![Combo28].column(1) = Like'B*'" -- left(Me![Combo28].column(1),1) = "B" "Me![Combo28].column(1) = 'Like'C*''" -- left(Me![Combo28].column(1),1) = "C" Warm Regards, Crystal remote programming and training Access Basics 8-part free tutorial that covers essentials in Access http://www.AccessMVP.com/strive4peace * (: have an awesome day * tony Jacobs wrote: I am having trouble with this code can anyone help. I have the follwing case statement that checks the value of the combo box, and based on that it will select which report to print, but I can not get it to work Select Case ReportPrint Case "Me![Combo28].column(1) = Like'B*'" stDocName = "Productsreport1" Case "Me![Combo28].column(1) = 'Like'C*''" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected Thanks in advance |
#8
|
|||
|
|||
Case statement Problem
No Damon;
The problem is that the same report opens in all cases. Which means that the case statement is not picking up the value of the combo box. The open report works perfectly and it tells me which records in the list box it is about to print. Now what I am trying to do is limit the list box to all items that start with a C, then print the C report Limit items to all that start with a B then print all items that Start with a B , then Print the B report (I called it report2 for example). The "ProductID IN " & strSelected statement.is flawless. I worked it out. Happy 4th of July. Proud to be an American. "Damon Heron" wrote in message . .. I would suggest you put a breakpoint at the beginning of your case stmt and step thru the code, checking values-- if the code picks the correct report name, then the problem is in your DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected statement. Damon "tony Jacobs" wrote in message ... Doug; No luck. No Errors but no results. Thanks for your time "Douglas J. Steele" wrote in message ... Given you were trying to use Column(1) in your first example, try Select Case Left(Me.Combo28.Column(1) & "", 1) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "tony Jacobs" wrote in message ... Sorry John; I did not work ! Any other ideas? "John Spencer" wrote in message ... Select Case Left(Me.Combo28 & "",1) Case "B" stDocName = "Productsreport1" Case "C" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected '================================================= === John Spencer Access MVP 2002-2005, 2007-2008 The Hilltop Institute University of Maryland Baltimore County '================================================= === strive4peace wrote: hi Tony "Me![Combo28].column(1) = Like'B*'" -- left(Me![Combo28].column(1),1) = "B" "Me![Combo28].column(1) = 'Like'C*''" -- left(Me![Combo28].column(1),1) = "C" Warm Regards, Crystal remote programming and training Access Basics 8-part free tutorial that covers essentials in Access http://www.AccessMVP.com/strive4peace * (: have an awesome day * tony Jacobs wrote: I am having trouble with this code can anyone help. I have the follwing case statement that checks the value of the combo box, and based on that it will select which report to print, but I can not get it to work Select Case ReportPrint Case "Me![Combo28].column(1) = Like'B*'" stDocName = "Productsreport1" Case "Me![Combo28].column(1) = 'Like'C*''" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected Thanks in advance |
#9
|
|||
|
|||
Case statement Problem
Hi Tony,
did you compile your code? '~~~~~~~~~ Compile ~~~~~~~~~ Whenever you change code, references, or switch versions, you should always compile before executing. from the menu in a VBE (module) window: Debug, Compile fix any errors on the yellow highlighted lines keep compiling until nothing happens (this is good!) ~~ if you run code without compiling it, you risk corrupting your database ~~~~~~~~~~~~~~~~ "Happy 4th of July. Proud to be an American." Happy Independence Day! Warm Regards, Crystal remote programming and training Access Basics 8-part free tutorial that covers essentials in Access http://www.AccessMVP.com/strive4peace * (: have an awesome day * tony Jacobs wrote: No Damon; The problem is that the same report opens in all cases. Which means that the case statement is not picking up the value of the combo box. The open report works perfectly and it tells me which records in the list box it is about to print. Now what I am trying to do is limit the list box to all items that start with a C, then print the C report Limit items to all that start with a B then print all items that Start with a B , then Print the B report (I called it report2 for example). The "ProductID IN " & strSelected statement.is flawless. I worked it out. Happy 4th of July. Proud to be an American. "Damon Heron" wrote in message . .. I would suggest you put a breakpoint at the beginning of your case stmt and step thru the code, checking values-- if the code picks the correct report name, then the problem is in your DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected statement. Damon "tony Jacobs" wrote in message ... Doug; No luck. No Errors but no results. Thanks for your time "Douglas J. Steele" wrote in message ... Given you were trying to use Column(1) in your first example, try Select Case Left(Me.Combo28.Column(1) & "", 1) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "tony Jacobs" wrote in message ... Sorry John; I did not work ! Any other ideas? "John Spencer" wrote in message ... Select Case Left(Me.Combo28 & "",1) Case "B" stDocName = "Productsreport1" Case "C" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected '================================================= === John Spencer Access MVP 2002-2005, 2007-2008 The Hilltop Institute University of Maryland Baltimore County '================================================= === strive4peace wrote: hi Tony "Me![Combo28].column(1) = Like'B*'" -- left(Me![Combo28].column(1),1) = "B" "Me![Combo28].column(1) = 'Like'C*''" -- left(Me![Combo28].column(1),1) = "C" Warm Regards, Crystal remote programming and training Access Basics 8-part free tutorial that covers essentials in Access http://www.AccessMVP.com/strive4peace * (: have an awesome day * tony Jacobs wrote: I am having trouble with this code can anyone help. I have the follwing case statement that checks the value of the combo box, and based on that it will select which report to print, but I can not get it to work Select Case ReportPrint Case "Me![Combo28].column(1) = Like'B*'" stDocName = "Productsreport1" Case "Me![Combo28].column(1) = 'Like'C*''" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected Thanks in advance |
#10
|
|||
|
|||
Case statement Problem
If the Case statement isn't working, then stDocName shouldn't have a value
and the OpenReport command should fail. Put a breakpoint in the code and make sure stDocName is, in fact, being set correctly. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "tony Jacobs" wrote in message ... No Damon; The problem is that the same report opens in all cases. Which means that the case statement is not picking up the value of the combo box. The open report works perfectly and it tells me which records in the list box it is about to print. Now what I am trying to do is limit the list box to all items that start with a C, then print the C report Limit items to all that start with a B then print all items that Start with a B , then Print the B report (I called it report2 for example). The "ProductID IN " & strSelected statement.is flawless. I worked it out. Happy 4th of July. Proud to be an American. "Damon Heron" wrote in message . .. I would suggest you put a breakpoint at the beginning of your case stmt and step thru the code, checking values-- if the code picks the correct report name, then the problem is in your DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected statement. Damon "tony Jacobs" wrote in message ... Doug; No luck. No Errors but no results. Thanks for your time "Douglas J. Steele" wrote in message ... Given you were trying to use Column(1) in your first example, try Select Case Left(Me.Combo28.Column(1) & "", 1) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "tony Jacobs" wrote in message ... Sorry John; I did not work ! Any other ideas? "John Spencer" wrote in message ... Select Case Left(Me.Combo28 & "",1) Case "B" stDocName = "Productsreport1" Case "C" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected '================================================= === John Spencer Access MVP 2002-2005, 2007-2008 The Hilltop Institute University of Maryland Baltimore County '================================================= === strive4peace wrote: hi Tony "Me![Combo28].column(1) = Like'B*'" -- left(Me![Combo28].column(1),1) = "B" "Me![Combo28].column(1) = 'Like'C*''" -- left(Me![Combo28].column(1),1) = "C" Warm Regards, Crystal remote programming and training Access Basics 8-part free tutorial that covers essentials in Access http://www.AccessMVP.com/strive4peace * (: have an awesome day * tony Jacobs wrote: I am having trouble with this code can anyone help. I have the follwing case statement that checks the value of the combo box, and based on that it will select which report to print, but I can not get it to work Select Case ReportPrint Case "Me![Combo28].column(1) = Like'B*'" stDocName = "Productsreport1" Case "Me![Combo28].column(1) = 'Like'C*''" stDocName = "Productsreport2" Case Else stDocName = "Productsreport" End Select DoCmd.OpenReport stDocName, acViewPreview, , "ProductID IN " & strSelected Thanks in advance |
Thread Tools | |
Display Modes | |
|
|