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 » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

WhereCondition



 
 
Thread Tools Display Modes
  #1  
Old February 28th, 2005, 12:37 AM
newguy
external usenet poster
 
Posts: n/a
Default WhereCondition

I have read some post that are related to the wherecondition but still can
get my problem solved. So here is my problem. I have a report that returns
all computers that have a given operating system. The user can select the OS
from a list box I can not get this to work. I keep getting a pop up asking
for the parameter. Here is my code that I have tried

temp = OSListBox.Value
DoCmd.OpenReport "OS", acViewPreview, , WhereCondition:=temp

and I tried this


DoCmd.OpenReport "OS", acViewPreview, , WhereCondition:=OSListBox.Value


I still get the second popup is there something wrong with my SQL that
generates the report. I have no idea where to go from here.

  #2  
Old February 28th, 2005, 01:19 AM
Marshall Barton
external usenet poster
 
Posts: n/a
Default

newguy wrote:

I have read some post that are related to the wherecondition but still can
get my problem solved. So here is my problem. I have a report that returns
all computers that have a given operating system. The user can select the OS
from a list box I can not get this to work. I keep getting a pop up asking
for the parameter. Here is my code that I have tried

temp = OSListBox.Value
DoCmd.OpenReport "OS", acViewPreview, , WhereCondition:=temp

I still get the second popup is there something wrong with my SQL that
generates the report. I have no idea where to go from here.



You have to have a complete conditional expression as would
appear in an SQL statement:

temp = "theosfield = """ & OSListBox.Value & """"

which will result in this kind of thing:

theosfield = "WinXP"

To see what result you want to achieve, create a query with
a sample os value as the criteria. Then switch to SQL view
and look at the WHERE clause.

--
Marsh
MVP [MS Access]
  #3  
Old February 28th, 2005, 01:21 AM
PC Datasheet
external usenet poster
 
Posts: n/a
Default

Base your report on a query and put the following expression in the criteria
of the OS field:
Forms!NameOfFormContainingOSListBox!OsListbox

Use the following code to open your report:
DoCmd.OpenReport "OS", acViewPreview

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications

www.pcdatasheet.com




"newguy" wrote in message
...
I have read some post that are related to the wherecondition but still can
get my problem solved. So here is my problem. I have a report that returns
all computers that have a given operating system. The user can select the

OS
from a list box I can not get this to work. I keep getting a pop up asking
for the parameter. Here is my code that I have tried

temp = OSListBox.Value
DoCmd.OpenReport "OS", acViewPreview, , WhereCondition:=temp

and I tried this


DoCmd.OpenReport "OS", acViewPreview, , WhereCondition:=OSListBox.Value


I still get the second popup is there something wrong with my SQL that
generates the report. I have no idea where to go from here.



  #4  
Old March 2nd, 2005, 03:31 AM
newguy
external usenet poster
 
Posts: n/a
Default

I think I got the string formatted correctly but I still get the second
prompt for the os value. Could it be a problem with the stored produce? Here
is what it looks like

select os, computerMake from computer where os like @os

here is the formatted string on the vba side

temp "os LIKE" & " ' " & OStext.value & " ' "

What do you think is going on I can't seem to get any were on this


"Marshall Barton" wrote:

newguy wrote:

I have read some post that are related to the wherecondition but still can
get my problem solved. So here is my problem. I have a report that returns
all computers that have a given operating system. The user can select the OS
from a list box I can not get this to work. I keep getting a pop up asking
for the parameter. Here is my code that I have tried

temp = OSListBox.Value
DoCmd.OpenReport "OS", acViewPreview, , WhereCondition:=temp

I still get the second popup is there something wrong with my SQL that
generates the report. I have no idea where to go from here.



You have to have a complete conditional expression as would
appear in an SQL statement:

temp = "theosfield = """ & OSListBox.Value & """"

which will result in this kind of thing:

theosfield = "WinXP"

To see what result you want to achieve, create a query with
a sample os value as the criteria. Then switch to SQL view
and look at the WHERE clause.

--
Marsh
MVP [MS Access]

  #5  
Old March 2nd, 2005, 07:24 PM
Marshall Barton
external usenet poster
 
Posts: n/a
Default

newguy wrote:

I think I got the string formatted correctly but I still get the second
prompt for the os value. Could it be a problem with the stored produce? Here
is what it looks like

select os, computerMake from computer where os like @os

here is the formatted string on the vba side

temp "os LIKE" & " ' " & OStext.value & " ' "



Ah, uh, sorry. Since I don't work with SQL Server, I don't
think I can help unravel this.

All I can say here is that I don't see why you're using Like
without a wildcard and that there are extra space characters
around the apostrophes. Seems like it sould be:
temp = "os = " & "'" & OStext.value & "'"
But I have no idea how that can end up as a useful parameter
in @OS.

--
Marsh
MVP [MS Access]
  #6  
Old March 4th, 2005, 03:35 PM
newguy
external usenet poster
 
Posts: n/a
Default

I thought I would post my solution just incase someone else had the same
problem.

I removed the where condition from my stored producer. I just selected all
the fields I needed and used a filter. Here is the code for the filter.

strFilter = "[com_OS]" & "=" & "'" & OStext.Value & "'"
If strFilter "" Then
DoCmd.OpenReport "FinalReport", acViewPreview
With Reports![FinalReport]
.Filter = strFilter
.FilterOn = True
.OrderBy = strOrderBy
.OrderByOn = True
End With
End If

"Marshall Barton" wrote:

newguy wrote:

I think I got the string formatted correctly but I still get the second
prompt for the os value. Could it be a problem with the stored produce? Here
is what it looks like

select os, computerMake from computer where os like @os

here is the formatted string on the vba side

temp "os LIKE" & " ' " & OStext.value & " ' "



Ah, uh, sorry. Since I don't work with SQL Server, I don't
think I can help unravel this.

All I can say here is that I don't see why you're using Like
without a wildcard and that there are extra space characters
around the apostrophes. Seems like it sould be:
temp = "os = " & "'" & OStext.value & "'"
But I have no idea how that can end up as a useful parameter
in @OS.

--
Marsh
MVP [MS Access]

 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
WhereCondition Ed the Redhead Using Forms 3 August 19th, 2004 12:41 PM
WhereCondition ignored when MS Access Form invokes Report yisraelharris Using Forms 1 June 1st, 2004 01:24 PM


All times are GMT +1. The time now is 01:55 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.