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  

Case statement Problem



 
 
Thread Tools Display Modes
  #1  
Old July 4th, 2008, 04:15 AM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
tony Jacobs
external usenet poster
 
Posts: 50
Default 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  
Old July 4th, 2008, 04:17 AM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
strive4peace
external usenet poster
 
Posts: 1,670
Default 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  
Old July 4th, 2008, 02:56 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 2,364
Default 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  
Old July 4th, 2008, 03:34 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
tony Jacobs
external usenet poster
 
Posts: 50
Default 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  
Old July 4th, 2008, 03:44 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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  
Old July 4th, 2008, 04:59 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
tony Jacobs
external usenet poster
 
Posts: 50
Default 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  
Old July 4th, 2008, 05:54 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
Damon Heron[_2_]
external usenet poster
 
Posts: 237
Default 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  
Old July 4th, 2008, 06:25 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
tony Jacobs
external usenet poster
 
Posts: 50
Default 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  
Old July 4th, 2008, 07:55 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
strive4peace
external usenet poster
 
Posts: 1,670
Default 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  
Old July 4th, 2008, 09:52 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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

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 04:46 PM.


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