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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |