stLinkCriteria error in Access 2007

Does anyone have any idea why this code will work in Access 2003 and NOT 
Access 2007?
The database is split (if that matters); and the error I get is "The 
Microsoft Office Access database engine could not find the object '0'. Make 
sure the object exists and that you spell its name and the path name 
correctly."


Private Sub Ok_Click()
On Error GoTo Ok_Click_Err
    'using the customer sub form for customer state report to filter the 
report, clicking ok will open report for selected state
Dim stDocName As String
Dim stLinkCriteria As String

    If Not IsNull(Me.Search_Results) Then
    stLinkCriteria = "[StateOrProvince] = """ & Me![Search Results] & """"
    End If

    DoCmd.Close acForm, "Customers Sub Form For Customer State Report"

    DoCmd.OpenReport "Customers by State", acPreview, acNormal,
WhereCondition = stLinkCriteria

Ok_Click_Exit:
    Exit Sub

Ok_Click_Err:
    MsgBox Err.Description
    Resume Ok_Click_Exit

End Sub

0
Randy
2/4/2008 5:07:41 PM
access 16762 articles. 3 followers. Follow

4 Replies
1097 Views

Similar Articles

[PageSpeed] 35

On Mon, 4 Feb 2008 11:07:41 -0600, Randy wrote:

> Does anyone have any idea why this code will work in Access 2003 and NOT 
> Access 2007?
> The database is split (if that matters); and the error I get is "The 
> Microsoft Office Access database engine could not find the object '0'. Make 
> sure the object exists and that you spell its name and the path name 
> correctly."
> 
> Private Sub Ok_Click()
> On Error GoTo Ok_Click_Err
>     'using the customer sub form for customer state report to filter the 
> report, clicking ok will open report for selected state
> Dim stDocName As String
> Dim stLinkCriteria As String
> 
>     If Not IsNull(Me.Search_Results) Then
>     stLinkCriteria = "[StateOrProvince] = """ & Me![Search Results] & """"
>     End If
> 
>     DoCmd.Close acForm, "Customers Sub Form For Customer State Report"
> 
>     DoCmd.OpenReport "Customers by State", acPreview, acNormal,
> WhereCondition = stLinkCriteria
> 
> Ok_Click_Exit:
>     Exit Sub
> 
> Ok_Click_Err:
>     MsgBox Err.Description
>     Resume Ok_Click_Exit
> 
> End Sub


Your arguments are not correct.
You placed acNormal in the Filter argument position.  Why?
acNormal is an Access constant whose value is 0.
You syntax has Access looking for a query filter named 0.
You don't need a Filter argument.
Your stLinkCritera belongs in the where clause argument position.

Try it this way.

DoCmd.OpenReport "Customers by State", acPreview, ,  stLinkCriteria
DoCmd.Close acForm, "Customers Sub Form For Customer State Report"

Note: If the name of the form this code is on is "Customers Sub Form
For Customer State Report", all you need, to close this form is:

DoCmd.OpenReport "Customers by State", acPreview, ,  stLinkCriteria
DoCmd.Close acForm, Me.Name

-- 
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
0
fredg
2/4/2008 5:53:15 PM
Looks like you're trying to use a named parameter in your OpenForm method. 
To do that, you need to use :=, not just =.

  DoCmd.OpenReport "Customers by State", acPreview, acNormal, _
    WhereCondition := stLinkCriteria


-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Randy" <randyandlucas@yahoo.com> wrote in message 
news:%2366$0B1ZIHA.4028@TK2MSFTNGP06.phx.gbl...
>
>
> Private Sub Ok_Click()
> On Error GoTo Ok_Click_Err
>    'using the customer sub form for customer state report to filter the 
> report, clicking ok will open report for selected state
> Dim stDocName As String
> Dim stLinkCriteria As String
>
>    If Not IsNull(Me.Search_Results) Then
>    stLinkCriteria = "[StateOrProvince] = """ & Me![Search Results] & """"
>    End If
>
>    DoCmd.Close acForm, "Customers Sub Form For Customer State Report"
>
>    DoCmd.OpenReport "Customers by State", acPreview, acNormal,
> WhereCondition = stLinkCriteria
>
> Ok_Click_Exit:
>    Exit Sub
>
> Ok_Click_Err:
>    MsgBox Err.Description
>    Resume Ok_Click_Exit
>
> End Sub
> 


0
Douglas
2/4/2008 6:31:00 PM
"fredg" <fgutkind@example.invalid> wrote in message 
news:d2td9piot4c6.1lna7c5kt9qy1$.dlg@40tude.net...
> On Mon, 4 Feb 2008 11:07:41 -0600, Randy wrote:
>
>> Does anyone have any idea why this code will work in Access 2003 and NOT
>> Access 2007?
>> The database is split (if that matters); and the error I get is "The
>> Microsoft Office Access database engine could not find the object '0'. 
>> Make
>> sure the object exists and that you spell its name and the path name
>> correctly."
>>
>> Private Sub Ok_Click()
>> On Error GoTo Ok_Click_Err
>>     'using the customer sub form for customer state report to filter the
>> report, clicking ok will open report for selected state
>> Dim stDocName As String
>> Dim stLinkCriteria As String
>>
>>     If Not IsNull(Me.Search_Results) Then
>>     stLinkCriteria = "[StateOrProvince] = """ & Me![Search Results] & 
>> """"
>>     End If
>>
>>     DoCmd.Close acForm, "Customers Sub Form For Customer State Report"
>>
>>     DoCmd.OpenReport "Customers by State", acPreview, acNormal,
>> WhereCondition = stLinkCriteria
>>
>> Ok_Click_Exit:
>>     Exit Sub
>>
>> Ok_Click_Err:
>>     MsgBox Err.Description
>>     Resume Ok_Click_Exit
>>
>> End Sub
>
>
> Your arguments are not correct.
> You placed acNormal in the Filter argument position.  Why?
> acNormal is an Access constant whose value is 0.
> You syntax has Access looking for a query filter named 0.
> You don't need a Filter argument.
> Your stLinkCritera belongs in the where clause argument position.
>
> Try it this way.
>
> DoCmd.OpenReport "Customers by State", acPreview, ,  stLinkCriteria
> DoCmd.Close acForm, "Customers Sub Form For Customer State Report"
>
> Note: If the name of the form this code is on is "Customers Sub Form
> For Customer State Report", all you need, to close this form is:
>
> DoCmd.OpenReport "Customers by State", acPreview, ,  stLinkCriteria
> DoCmd.Close acForm, Me.Name
>
> -- 
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail

Sweet! Thanks Fred, this is what I needed!!!

As to why the code was like it was, got me; I just threw it together from 
reading posts. Like I said, it works fine in the older Access version, so 
there was no need to modify it in the past. 

0
Randy
2/4/2008 8:12:37 PM
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message 
news:eNNuYw1ZIHA.5160@TK2MSFTNGP05.phx.gbl...
> Looks like you're trying to use a named parameter in your OpenForm method. 
> To do that, you need to use :=, not just =.
>
>  DoCmd.OpenReport "Customers by State", acPreview, acNormal, _
>    WhereCondition := stLinkCriteria
>
>
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Randy" <randyandlucas@yahoo.com> wrote in message 
> news:%2366$0B1ZIHA.4028@TK2MSFTNGP06.phx.gbl...
>>
>>
>> Private Sub Ok_Click()
>> On Error GoTo Ok_Click_Err
>>    'using the customer sub form for customer state report to filter the 
>> report, clicking ok will open report for selected state
>> Dim stDocName As String
>> Dim stLinkCriteria As String
>>
>>    If Not IsNull(Me.Search_Results) Then
>>    stLinkCriteria = "[StateOrProvince] = """ & Me![Search Results] & """"
>>    End If
>>
>>    DoCmd.Close acForm, "Customers Sub Form For Customer State Report"
>>
>>    DoCmd.OpenReport "Customers by State", acPreview, acNormal,
>> WhereCondition = stLinkCriteria
>>
>> Ok_Click_Exit:
>>    Exit Sub
>>
>> Ok_Click_Err:
>>    MsgBox Err.Description
>>    Resume Ok_Click_Exit
>>
>> End Sub
>>
>
>

Thanks for the reply Doug, I actually did try your recommended change based 
off of another button I let the Access Wizard create; but it didn't work 
either. Fred's suggestion in the above post did work for me. I believed I 
had the issue narrowed down to the "WhereCondition" statement was but just 
didn't know how to fix it. I guess I'm still wondering why it didn't work... 

0
Randy
2/4/2008 8:20:33 PM
Reply:

Similar Artilces:

using photo gallery pages in publisher 2007
Hi, I've made a website using pub 2003. In it I put photo gallery pages, both with links and not. I'm in the process of making a new site using 2007 and can't find the "page types" help. Does 2007 support the photo gallery pages and, if so, how do I find them to insert into my document? Thanks, David Insert Page > Photos and you will get three options. In the future, please post web design questions in the web group and we will try to help you there: microsoft.public.publisher.webdesign DavidF "clueless" <clueless@discussions.microsoft.com>...

series of dates, step by 1, Mon-Thurs only, for 2007
I would like to have all the dates I'm going to work from Jan 29/07 to Dec 31/07, leaving out all Fri, Sat and Sun dates. I'm not sure how to do this. Can someone help me please?? Thanks!! ....Lisa, using Excel 2003 "Lisa Hetherington" <gerry.l...@sympatico.ca> wrote... >I would like to have all the dates I'm going to work from Jan 29/07 to Dec >31/07, leaving out all Fri, Sat and Sun dates. .... Enter Jan 29 in cell A1, enter the following formula in A2, =A1+IF(WEEKDAY(A1,2)=4,4,1) and fill A2 down as far as needed. Perfect!! Thank you. ....Lisa...

Error C1038a21
We are partway through a migration from Exchange 5.5 to Exchange 2003. About a week ago we moved all of our Public Folders (a few at a time) to the new server and everthing has been running fine since. Today however, one of our mail enabled public folders stopped accepting mail. Up until today it was working fine. When I try to look at the properties of the folder in ESM I get the following... "The mail proxy for this folder could not be found. This may be due to replication delays. The mail enabled pages will not be shown. Id no:C1038a21 Exchange System Manager" This f...

How do you copy plain text from a Word 2007 document?
I was wondering if there is a way to copy only plain text from a Word document, without all of the formatting information? No - but you can paste without the formatting information into Word 2007. What are you trying to do? -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "...

Word 2007 ink options
I have a 'pen mouse' (A 'bamboo tablet' if this makes things clearer) and have only just discovered that on the word 2007 toolbar there are 'ink' options which allow me to scribble and draw in word documents. Every time I start Word the pens go back to default settings - e.g. the felt tip pen is always red and a certain width. Is there anyway to change the default settings on this particular function? Thanks -- doghouseriley ...

Pivot Tables 2003 v 2007
So I have an odd question.. I have a pivot table (created in Excel 2003) that links to data (also created in Excel 2003). This Pivot Table has a report filter that allows me to select dates. Right now I do not have the "all" selected in this report filter but actually have the days selected. When I add new data to the data.xls and refresh my pivot table it automatically adds the new dates and selects them automatically to show up in my Pivot table results... This is what I want to happen. Now, I also have a pivot table (created in Excel 2007) that links to the same d...

Outlook Web Access #43
I can no longer delete messages or attach documents when using Outlook Web Access. The error I receive is 'cannot delete (or attach) item'. Any suggestions on how to fix this? Thank you, CB ...

Exchange 2007 And Daylight Savings Time Update
Is there a patch I need for Day light savings time and Exchange 2007? Thanks! No CDO patch required (no equivalent of KB 926666). However, the Windows Server 2003 OS will required KB 931836 time zone update and Calendar-items in 2007-hosted mailboxes created using old DST 2006 rules will need to be rebased. -- Bharat Suneja MVP - Exchange www.zenprise.com NEW blog location: exchangepedia.com/blog ---------------------------------------------- "D303M" <D303M@discussions.microsoft.com> wrote in message news:A3132ABD-4614-402F-9654-61EA72501112@microsoft.com... > I...

Independently Resize Control in Access 2007
I've only recently begun using Access 2007 after many years of 2002/2003. One thing I don't get is how to independently resize a control on a form in 2007. The "help" offers this explanation: "This article describes how to remove controls from layouts, after which you can move and resize them without affecting other controls." Well, it does indeed show how to REMOVE a control. No problem. But then how are you supposed to "move and resize" it when it's not on the form anymore. I mean, it was removed as promised! This must be simpler th...

Does CRM 3.0 work on Outlook Web Access ?
Does Microsoft dynamics CRM 3.0 work on Outlook Web Access ? No, there is no integration with OWA. Dave "Misha" <Misha@discussions.microsoft.com> wrote in message news:B5CCB639-F8AF-4901-AF52-509C7FAC338C@microsoft.com... > Does Microsoft dynamics CRM 3.0 work on Outlook Web Access ? ...

Exmerge error
I downloaded exmerge this morning. When I try to run it to play around with it, I get this message "This application has failed to start because EXCHMEM.dll was not found. Re-installing the application may fix this problem." I searched and found the .dll file on the machine. I do not want to re-install Exchange 2003. Can anyone shed some light on this? Thanks in advance. Jim Copy all the Exmerge files to the exchsrvr\bin directory. -- Mark Fugatt Exchange MVP http://www.exchangetrainer.com http://www.msexchange.org "J. Huber" <jimh@great!harvest.com> wrote in me...

error bars display
I am plotting graphs with custom error bars in Excel 2003. If I change the size of the error bars (by changing the cells that the custom error bars refer to), the error bar patterns sometimes, but not always, change by themselves. For example, I normally set the error bars to medium line thickness and with a cap on the ends, but when I change the source data for the error bars, some of them change to a different line thickness and/or no cap on the ends. They are not even consistent within the same series. About 2-5 out of 12 error bars in each graph (not always the same 2-5) get changed...

Macro code produces error
Version: 2004 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Hi everyone, <br><br>When I test the macro code below on Word 2004, I get the following error: <br><br>Compile error: user-defined type not defined <br><br>This only happens when I run the code on my mac. When I test it on a PC with Word 2007, it works fine. <br><br>I wondered if someone could run it for me and tell me if you get the same error? <br><br>Appreciate any assistance. <br><br>Sub GetImage() <br><br> Dim dlg As Office.Fi...

Pivot Table Error message
I have created a pivot table in an Excel workbook. When I open the work book, I can a message telling me that there are errors that Excel has repaired and to save the workbook. There is also a log file that is as follows: Microsoft Excel File Repair Log Errors were detected in file 'C:\projects\marketing requests.xls' The following is a list of repairs: Repairs were made to PivotTable report 'PivotTable1' on '[marketing requests.xls]MarketingAnalysis'. but the message keeps happening each time I open the workbook, whether I choose to replace the cells or save...

MS CRM 1.2 CrystalReportViewer Error
Hello, I have installed the german MSDN version of the MS CRM 1.2 - most parts are doing their work, but have invested now hours of searching, but still not found a solution to get the crystal reports running. Always when opening a report (e.g. the activity list report, http://<server name>/reports/viewer/html/viewer.aspx?id=189) I'm receving an error message, like this: "Fehler im Abfragemodul. Datei c8036e4ef934e114.rpt." Translated into english it can be called maybe "Error in query module. File c8036e4ef934e114.rpt." - but didn't found some error mes...

Requisition Management in Business Portal
I'm receiving this error message when trying to create a purchase requisition in Microsoft Business Portal (GP10). I'm using I.E.7. I tried registering all the DLLs mentioned in kb article http://support.microsoft.com/?kbid=281679 and received some error messages for the following dlls mshtml.dll - The file cannot be registered "entry point not found" browseui.dll - Module couldn not be found After this, I tried registering the mbfwebBehaviors.dll (first I dropped it into the i386 and system32 folders) , I got the following message : Load library ("mbfwebBehavio...

I can't seem to get Outlook 2007 working
I am running Office 2007 with Vista. I have recently tried to get Outlook 2007 working but when I use the wizard to set it up with POP3 etc and the usual incoming server details (which are all correct) it won't accept my password/login for my mail server. I know it is all correct but it just won't go on to set up. Any ideas? In article <A6D9D38F-2CC7-4B6B-82B4-D186D8761C3F@microsoft.com>, Richard@discussions.microsoft.com says... > > I am running Office 2007 with Vista. I have recently tried to get Outlook > 2007 working but when I use the wizard to set ...

Access Reports in VB6
> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3341467740_2106995 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: 8bit Hello everyone, I am programming a simple VB6 program to add data to an Access DB and retrieve reports from it depending on the criteria. I was trying to create the reports inside VB6 using the DATAREPORTS but I was unsuccessful because I realized it was hard to create the print outs and group them. I was not able to group th...

Access 97 compatible with Microsoft 2000
Our office recently converted to Microsoft 2000, and we have Access 1997. I am wondering if this is not a good mix since Access keeps locking up on us. Any opinions? Colleen You will run into trouble when someone with Access 2000 converts an Access 97 database to 2000. The person with 97 will not be able to open it. For those who use multiple versions of Access, for whatever reason, I recommend our product Total Access Startup. http://www.fmsinc.com/Products/startup/index.asp Let me know if you have any other questions about it. -- Rob -=-=-=-=-=-=-=-=-=-=-=-=-=-=- Problems with you...

Edit List Item in Access 2007
I have been adding the new values into item list for the past few days, but when I continue to do so today, all the values are keyed into the list but not able to save in the list after clicking 'OK'. Any reason for this sudden change? Appreciate your kind response... Thanks & regards, Lawrence Just an idea When you say > I have been adding the new values into item list for the past few days this sounds like you should not be using a list - are you adding zillions on items??. You could change it to a form/datasheet view and add controls to select items. O...

How do I stop Facebook importing birthdays into Outlook 2007
Just now I got a HUGE long list of overdue appointments pop up. All of them are people's birthdays and all are from Facebook. In one instance alone, a friend has his birthday listed 4 times. How can I stop Facebook sending this info to Outlook? It's really starting to annoy me, now. Hi Marts, Have you installed any Facebook addins to your Outlook 2007? Try blocking them in Outlook options. Marts wrote: > Just now I got a HUGE long list of overdue appointments pop up. All of them are > people's birthdays and all are from Facebook. > > In one instance alone, a f...

Validation Rules in Access 2000
Afternoon, Apologies if this topic has been covered but i struggled to find it if it has. I'm a bit of a novice in Access so i was hoping someone could help me. At our warehouse we house alot of products from different companies, when they come in the door we would have pallets of the same stock and they would have a Product Code then "x" amount of days later some stock would go out to a store. We have a basic DB to keep everything in order but we are having problems with human error. i.e. a product code might be 12345-A and the inputter might put 12345/A or even type it wrong ...

Import external data from Access query with Variable
Hello - I have been able to record a macro where I can change the "inventory.Area" from US006 to US007. I would like to be able to make the area a variable and pick up the area code from within a spreadsheet. For example, I am doing reporting for 10 areas and would like to have one template that pulls in the data from Access for one area, saves the file, goes to the next area, pulls in that data from Access and so on. But I cannot figure out how to make the area in the VBcode below a variable. Any help would be appreciated. Sub Macro3() With Selection.QueryT...

Report error Run Time error 2427
I have combo box where I have list of months and years. When I choose January 2009. It gives me a 2427 run time error. When I debug it takes me to: Private Sub Detail_Format(Cancel As Integr, FormatCount As Integer) If Me.somefield>0 Then Me.Detail.BackColor = 14408667 Else Me.Detail.BackColor = 16777215 If me.[anotherfield] = "Followup" Then Me.Label22.Visible = False End Sub However, when I choose any other month I get my report in view form. Can someone please explain and help me out?? Thank you. I would try: Private Sub Detail_Format(Cancel As Integr, F...

Failed to get language error...
but I only get it on weekends. It seems to be tied to the warmup script I am running for SharePoint/Project 2007. The script hits these pages: /Pages/default.aspx /project/default.aspx /project/_layouts/pwa/admin/admin.aspx /10887/ every 10 minutes. This seems to be the timing of the errors on the weekend. What I don't understand is why it only happens on the weekend. The servers are under virtually no load during the weekends. ...