f



"Run-Time Error '3012' : Object "------------" already exists

Dear Sir or Madam :

Hello !

Newbie to Access 2010 programming here ; I've a form which is almost complete -- HOWEVER, whenever selecting a specific pull-down, I'm thrown the error : "Run-time error '3012' : Object "------------" already exists "

Where "------------" is a 'set' statement...  Hmmm...  So...  My code's below and if anyone can take a gander, it would be greatly appreciated !  ( The error checking MsgBoxes are showing me the data being returned is correct. ) It will help my office run more smoothly...  Thanks in advance !  -- B.

Private Sub UserID_Click()

Dim dbs As Database, qdf As QueryDef, sqlQry As String, strSQL As String

Set dbs = CurrentDb

    If (Court222 = "Middlesex") Then
        strSQL = "SELECT Middlesex FROM Pricing WHERE Testpanel ='" & Panel & "'"
    ElseIf (Court222 = "Suffolk") Then
        strSQL = "SELECT Suffolk FROM Pricing WHERE Testpanel ='" & Panel & "'"
    ElseIf (Court222 = "Essex") Then
        strSQL = "SELECT Essex FROM Pricing WHERE Testpanel ='" & Panel & "'"
    Else
        strSQL = "SELECT Norfolk FROM Pricing WHERE Testpanel ='" & Panel & "'"
    End If
    
    MsgBox "strSQL: " & strSQL
    
   'THE LINE BELOW IS WHERE THE ERROR OCCURS FOR "SECONDQUARTER"
    Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

    Amount = qdf
    

End Sub

0
bdkodt (1)
1/31/2014 5:57:23 PM
comp.databases.ms-access 42670 articles. 0 followers. Post Follow

2 Replies
809 Views

Similar Articles

[PageSpeed] 26

On 31/01/2014 17:57:24, bdkodt wrote:
> Private Sub UserID_Click()
> 
> Dim dbs As Database, qdf As QueryDef, sqlQry As String, strSQL As String
> 
> Set dbs = CurrentDb
> 
> If (Court222 = "Middlesex") Then
> strSQL = "SELECT Middlesex FROM Pricing WHERE Testpanel ='" & Panel & "'"
> ElseIf (Court222 = "Suffolk") Then
> strSQL = "SELECT Suffolk FROM Pricing WHERE Testpanel ='" & Panel & "'"
> ElseIf (Court222 = "Essex") Then
> strSQL = "SELECT Essex FROM Pricing WHERE Testpanel ='" & Panel & "'"
> Else
> strSQL = "SELECT Norfolk FROM Pricing WHERE Testpanel ='" & Panel & "'"
> End If
> 
> MsgBox "strSQL: " & strSQL
> 
> 'THE LINE BELOW IS WHERE THE ERROR OCCURS FOR "SECONDQUARTER"
> Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)
> 
> Amount = qdf
> 
> 
> End Sub

Are you saying you actually have 4 fields in your Pricing table called
"Essex, Suffolk", "Norfolk" and "Middlesex"

Have you also fields NAMED all the other counties?

I suspect that "Essex, Suffolk", "Norfolk" and "Middlesex" are actually the
value of a field called "County"

Anyway, when you get it to run correctly, you will create the Query
"SecondQuarter". If you run the routine a second time it will fail because
the query already exists and you can't create it again.

If you really want to have a new version of SecondQuarter then you need

    On Error Resume Next
    DoCmd.DeleteObject acQuery, "SecondQuarter"
 anywhere before

Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

Phil

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

0
Phil
1/31/2014 7:04:28 PM
Phil wrote:
> On 31/01/2014 17:57:24, bdkodt wrote:
>> Private Sub UserID_Click()
>>
>> Dim dbs As Database, qdf As QueryDef, sqlQry As String, strSQL As
>> String
>>
>> Set dbs = CurrentDb
>>
>> If (Court222 = "Middlesex") Then
>> strSQL = "SELECT Middlesex FROM Pricing WHERE Testpanel ='" & Panel
>> & "'" ElseIf (Court222 = "Suffolk") Then
>> strSQL = "SELECT Suffolk FROM Pricing WHERE Testpanel ='" & Panel &
>> "'" ElseIf (Court222 = "Essex") Then
>> strSQL = "SELECT Essex FROM Pricing WHERE Testpanel ='" & Panel & "'"
>> Else
>> strSQL = "SELECT Norfolk FROM Pricing WHERE Testpanel ='" & Panel &
>> "'" End If
>>
>> MsgBox "strSQL: " & strSQL
>>
>> 'THE LINE BELOW IS WHERE THE ERROR OCCURS FOR "SECONDQUARTER"
>> Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)
>>
>> Amount = qdf
>>
>>
>> End Sub
>
> Are you saying you actually have 4 fields in your Pricing table called
> "Essex, Suffolk", "Norfolk" and "Middlesex"
>
> Have you also fields NAMED all the other counties?
>
> I suspect that "Essex, Suffolk", "Norfolk" and "Middlesex" are
> actually the
> value of a field called "County"
>
> Anyway, when you get it to run correctly, you will create the Query
> "SecondQuarter". If you run the routine a second time it will fail
> because
> the query already exists and you can't create it again.
>
> If you really want to have a new version of SecondQuarter then you
> need
>
>    On Error Resume Next
>    DoCmd.DeleteObject acQuery, "SecondQuarter"
> anywhere before
>
> Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)
>
> Phil
>

Also the line   "Amount = qdf"    is pointless.  For a start "Amount" is not 
defined and I suspect it is intended to be a variable to receive some data 
which will not happen doing this.   This line will not run the query nor 
yield any data even if "Amount" was defined.  You need to study more the 
relationship between querydefs, recordsets and fields.  You would open a 
recordset based on the querydef then inspect fields within it.



D



0
David
1/31/2014 9:39:33 PM
Reply:

Similar Artilces:

how to make ["a","b",["c","d"],"e"] into ['a', 'b', 'c', 'd', 'e'] ?
--001a11c34e8edbc7c404f6a94bbe Content-Type: text/plain; charset=ISO-8859-1 >>> x=["a","b",["c","d"],"e"] >>> y=x[2] >>> y ['c', 'd'] >>> x.insert(2,y[0]) >>> x ['a', 'b', 'c', ['c', 'd'], 'e'] >>> x.insert(3,y[1]) >>> x ['a', 'b', 'c', 'd', ['c', 'd'], 'e'] >>> del x[4] >>> x ['a', 'b', 'c', 'd', &#...

Why """, not '''?
Why is """ the preferred delimiter for multi-line strings? On Mar 5, 9:56 am, MartinRineh...@gmail.com wrote: > Why is """ the preferred delimiter for multi-line strings? Is it ? FWIW, I use single quotes whenever I can and double whenever I have to (i.e. rarely). George On Wed, 5 Mar 2008 06:56:24 -0800 (PST) MartinRinehart@gmail.com wrote: > Why is """ the preferred delimiter for multi-line strings? Where did you see that? The only place I saw it was the style guide and it was only talking about docstrings. Even there they used """ as an example but the text talked about using triple quotes as opposed to single quotes even when it is a single line docstring. I don't think that there is any preference for """ over ''' in general. Pick one for consistiency. Note however that """ can't be confused with " followed by ' as in "'A' is the first letter of the alphabet." -- D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. D'Arcy J.M. Cain wrote: > Where did you see that? The only place I saw it was the style guide > and it was only talking about docstrings. PEP 8 and 257, and you're right, they are both about docstrings. Also, I'd never se...

Compile time error: "error: 'write_n' is not a member of 'ACE'"
Hi All, ACE VERSION: 5.5.6 HOST MACHINE and OPERATING SYSTEM: LINUX, Kernel 2.6.19-1.2288.fc5, i686 I tried to compile the program given below, but was giving following compilation error: Please help me to compile this proram --------------------------------------- COMPILATION------------------------------------------ [root@paresh ACE_MSG_BLOCK]# g++ main.C -o main -lACE -IACE_ROOT main.C: In function 'int main(int, char**)': main.C:9: error: 'read_n' is not a member of 'ACE' main.C:20: error: 'write_n' is not a member of 'ACE' ----------------------------------END COMPILATION-------------------------------------------- ---------------------------------------------PROGRAM main.C--------------------------------------------- #include "ace/OS.h" #include "ace/Message_Block.h" int main(int argc, char* argv[]) { ACE_Message_Block *head = new ACE_Message_Block(BUFSIZ); ACE_Message_Block *mblk = head; for(;;) { ssize_t nbytes = ACE::read_n(ACE_STDIN, mblk- >wr_ptr(), mblk->size()); if(nbytes <= 0) break; mblk->wr_ptr(nbytes); mblk->cont(new ACE_Message_Block(BUFSIZ)); mblk = mblk->cont(); } for(mblk = head; mblk != 0/*NULL POINTER*/; mblk = mblk- >cont()) { ACE::write_n(ACE_STDOUT, mblk-&g...

(mapcar 'quote '("1" "2" "3" "4"))
(mapcar 'quote '("1" "2" "3" "4")) returns ((quote "4") (quote "4") (quote "4") (quote "4")) Interesting and (for me) unexpected. Because (mapcar 'read '("1" "2" "3" "4")) returns (1 2 3 4) and (mapcar 'princ '("1" "2" "3" "4")) gives 1234("1" "2" "3" "4") Why isn't (mapcar 'quote '("1" "2" "3" "4")) returning ((quote "1") (quote "2") (quote "3") (quote "4")) Tom Haws www.hawsedc.com Probably has to do with the fact that 'arg and (quote arg) are equivalent, and LISP gets confused by the construct 'quote, which is about the same as (quote (quote arg)). But I don't pretend to know all of the mechanics of the error; the results are somewhat different in R14, BTW: Command: (mapcar 'quote '("1" "2" "3" "4")) ((<Subr: #22e3e40> "4") (<Subr: #22e3e40> "4") (<Subr: #22e3e40> "4") (<Subr: #22e3e40> "4")) ___ "Tom Haws" <hawstom@despammed.com> wrote in message news:77317472.0309160733.45ea9d8c@posting.google.com... > (mapcar 'quote '("1" "2" "3"...

Re: [ace-users] Compile time error: "error: 'write_n' is not a member of 'ACE'"
Hi, You lack an include, include "ace/ACE.h" in your program Regards, Johnny Willemsen Remedy IT Postbus 101 2650 AC Berkel en Rodenrijs The Netherlands www.theaceorb.nl / www.remedy.nl "Paresh" <pareshspednekar@gmail.com> wrote in message news:<1173985162.346951.209100@y66g2000hsf.googlegroups.com>... > Hi All, > > ACE VERSION: 5.5.6 > HOST MACHINE and OPERATING SYSTEM: LINUX, Kernel 2.6.19-1.2288.fc5, > i686 > > I tried to compile the program given below, but was giving following > compilation error: > Please help me to compile this proram > > --------------------------------------- > COMPILATION------------------------------------------ > [root@paresh ACE_MSG_BLOCK]# g++ main.C -o main -lACE -IACE_ROOT > main.C: In function 'int main(int, char**)': > main.C:9: error: 'read_n' is not a member of 'ACE' > main.C:20: error: 'write_n' is not a member of 'ACE' > ----------------------------------END > COMPILATION-------------------------------------------- > > > > ---------------------------------------------PROGRAM > main.C--------------------------------------------- > > #include "ace/OS.h" > #include "ace/Message_Block.h" > > int main(int argc, char* argv[]) { > ACE_Message_Block *head = new ACE_Message_Block(BUFSIZ); > ...

Mandis Quotes (aka retiring """ and ''')
Jef Raskin (namedropping) has pointed me at a neat scheme for quoting arbitrary textual matter called "Mandis quotes". Since google is ignorant of the phrase, I presume that Jef made it up. It is disgustingly simple, and very Pythonesque. Here's how it works: If you have a string that doesn't have any single quotes in it, you surround the string by a pair of doubled single quotes. ''Like this''. No backslash interpolation. If you want a character in there, you put it in there (yes, I know, stand down your armies). Clearly, then, any character except a si...

Can't "mk CONF=9pcdisk" --> gives error "rc: #d/0: token '=': syntax error"
I'm in /sys/src/9/pc and I type `mk CONF=9pcdisk` and rc gives me the error "rc: #d/0: token '=': syntax error". Why is this? Just doing mk works fine (I think). Thanks! Plan9 looks very cool... just finished reading through intro (all of it). you're using backquotes, why? that would be `{mk CONF=3D9pcdisk} in rc's syntax. now to compile that kernel the syntax is: % mk 'CONF=3Dpcdisk' now are you sure you want a pcdisk?=20 On Jul 19, 2012, at 6:07 AM, kalaracey@gmail.com wrote: > I'm in /sys/src/9/pc and I type >=20 ...

'Parse error' problem in "isset" and "empty"
I've been having some problems with a parse error that I can't figure out (PHP 4.3.11 on Solaris9). Sample code: <?php // getting strange parse errors on this class A { var $value; function A() { $this->value = 1; } function getValue() { return $this->value; } } $a = new A(); if (!empty($a->getValue())) { echo "success"; } else { echo "failure"; } ?> The result of this is: Parse error: parse error, unexpected '(', expecting ')' in /foo/public_html/parse_errors.php on line 15 I also get the same effect with "iss...

"Select" & "Order By" OK- ''WHERE'' Does'nt Work !
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've reduced my form request to a simple text string entry, instead of my desired optional parameters. As i have been stuck with a single unfathomable glitch for over a year. Basically, if i enter queries such as ; "select * from table" "select * from table order by artist", it works perfectly. However if i introduce the 'where' option, as in "select * from table where ...

ERROR: "Method 'Connection' of object '_Current Project' failed."
I have created a front-end application and back-end database. Everytime that I opened the program in the past, it open just fine with no errors when linking to the back-end tables. lately, I get the following error message whenever I open my application: ERROR: "Method 'Connection' of object '_Current Project' failed. Check to see if you installed the tables used for storing data is in the default directory. -2147024769 After clicking, "OK", my application continues on to open anyway. I have checked the application to determine if the intended location for...

run-time error 2471 'The object doesn't contain the Automation object 'qry_prodreport_ALL.SSN."
I'm getting this error: run-time error 2471 'The object doesn't contain the Automation object 'qry_prodreport_ALL.SSN." Here is the code: Private Sub GroupFooter0_Format(Cancel As Integer, FormatCount As Integer) Dim strcount As Double, strpts As Double strcount = Nz(DSum("[Miles]", "Productivity", "[SSN]= qry_prodreport_ALL.[SSN]" & _ "and [Date] >= DateAdd(ww, -13, (Now))"), 1) strpts = strcount / 13 Me.txtpts = strpts End Sub qry_prodreport_ALL definitely exists, and it returns a field called "SS...

Re: Mandis Quotes (aka retiring """ and ''')
Russell Nelson wrote: > If you need to put a single quote in, then you put > an arbitrary string in-between the single quotes which does NOT > appear in the string. For example, "Bill's house" becomes > 'x'Bill's house'x'. So possible examples might be: 'xx'somebody's mother'xx' 'xy'somebody's father'xy' 'wink'somebody's uncle'wink' 'quote'somebody's body'quote' not terrible easy on the eyes, and why use the single quote at all? Why no= t use a similar pattern li...

ERROR: "Method 'Connection' of object '_Current Project' failed. -2147024769"
Continue to get error message. Here is an update of my problem and everything that I have done to correct it. I have created a front-end application and back-end database. I have code that automatically links the front-end application to the back-end database for whenever I provide a patch or upgrade. Everytime that I opened the program in the past using either Access 2002 and 2003, it open just fine with no errors when linking to the back-end tables. Lately, I get the following error message whenever I open my application: ERROR: "Method 'Connection' of object '_Current Project' failed. Check to see if you installed the tables used for storing data is in the default directory. -2147024769" After clicking, "OK", my application continues to open and re-links to the back-end tables anyway. Yes, all the data displays in the application front-end data fields. I removed all the links to the back-end tables; re-imported the back-end tables; same problem. This was then followed by with creating a new application re-combining the front and back-ends (no problems occurred in loading and using the application) and preceded to re-split the application again. I continue to receive the above error. I went to backups and earlier versions of my application, up to 12 months, and now, they give out the same above error message. Could this be an Access problem? John John Phelan wrote: > Continue to get error message. > > Here is an update...

ERROR: "Method 'Connection' of object '_Current Project' failed. -2147024769"
I have created a front-end application and back-end database. I have code that automatically links the front-end application to the back-end database for whenever I provide a patch or upgrade. Everytime that I opened the program in the past using either Access 2002 and 2003, it open just fine with no errors when linking to the back-end tables. Lately, I get the following error message whenever I open my application: ERROR: "Method 'Connection' of object '_Current Project' failed. Check to see if you installed the tables used for storing data is in the default direct...

solving a "ActiveX component can't create object or return reference to this object Run Time Error 429"
I open Access 2007, open the mydatabase.accdb database, run the below code as a macro and it runs fine. But, if I open a Word 2007 document, try to run this as a macro, I get the error "Run Time Error 429 ActiveX component can't create object or return reference to this object". on the line where I am trying to open a handle to the database at OpenDatabase("C:\mydatabase.accdb"). I want the below part to run in a Word document so it can read the data in the last column of every row of all the tables in a document, populate a recordset with the values...

'quote' to `quote'
Hi, what is the way to change 'shocking,' said Sally into `shocking', said Sally automatically as Tex read the author.txt file? Does this method also change "whatever happens," he said into ``whatever happens.'' he said. David R David R <angel_ov_north@tiscali.co.uk> wrote: > what is the way to change 'shocking,' said Sally > into `shocking', said Sally > automatically as Tex read the > author.txt file? It is possible (e.g. via an active '). But I suspect, this is a lot easier using a script language or similar. Also you ...

Re: Mandis Quotes (aka retiring """ and ''') #2
Russell Nelson notes: > = > Choose poor examples, and then criticize them as poor choices? > = true enough, but the suggested scheme introduces another variable into the = language syntax; I might always make good choices <wink> on what delimiter = I choose, but I might also end up working on code written by someone else w= ho makes less good choices. Or vice versa. = > Exactly. It really would be better to have one(1) string literal > which can quote anything without reverting to backslashing. Why one? > Simpler parsing, simpler learning of the language, fewe...

""""""""""""""""""""""ADD ME""""""""""""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfo Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... We look forward to build a ve...

Request " ''BOLD' Error in process BDUGKSH ''NORMAL' "
How could I put bold characters in request command, like this : Request " ''BOLD' Error in process BDUGKSH ''NORMAL' " Thanks in advance. In article <ddf392ea.0311131305.595344d3@posting.google.com>, contracer11@uol.com.br (Shiva MahaDeva) writes: > How could I put bold characters in request command, like this : > > Request " ''BOLD' Error in process BDUGKSH ''NORMAL' " > > Thanks in advance. It depends on what kind of terminal it's going to. In article <ddf392ea.0311131305.595344d3@posting.google.com>, contracer11@uol.com.br (Shiva MahaDeva) writes: >How could I put bold characters in request command, like this : > >Request " ''BOLD' Error in process BDUGKSH ''NORMAL' " Not at all. For security reasons, OPCOM removes nonprintable characters and replaces them by a dot. You want a user to switch your oper terminal in a permanent self test loop ? -- Peter "EPLAN" LANGSTOEGER Network and OpenVMS system specialist E-mail peter@langstoeger.at A-1030 VIENNA AUSTRIA I'm not a pessimist, I'm a realist koehler@eisner.nospam.encompasserve.org (Bob Koehler) writes in article <3vFFBoUQw5N$@eisner.encompasserve.org> dated 13 Nov 2003 16:04:22 -0600: >In article <ddf392ea.0311131305.595344d3@posting.google.com>, contracer11@uol.com.br (Shiva MahaDeva) writes: >> How could I put ...

=("|\')?([^ "\']*)("|\')?.*>([^<]*)</A>'
Hello. Well, I found this piece of code on php.net. Thats fine but where can i find explanation for all these ("|\')?([^ "\']*)("|\')?.*>([^<]*)' syntax so that I can construct my own rules for all kind of eregi preg and oter match functions ? Transform HTML links into plain-text "links" with the URL visible function AHREF2text($string) { return eregi_replace('<A .*HREF=("|\')?([^ "\']*)("|\')?.*>([^<]*)</A>', '[\\4] (link: \\2)', $string); } And another simple question, maybe ...

Exception running GNU module "op25_grc.py" : AttributeError: 'gr_hier_block2_sptr' object has no attribute 'set_callback'
I am using using ubuntu 12.10 i am trying to run a python block, namely OP2= 5, in GNU Radio Companion v3.6.3-35-g4435082f, which uses python version 2.= 7.3 for some reason although python3.2 is in the lib folder. I run the foll= owing trace command in terminal: ~$ python -m trace --count -C . op25_grc.py Here is the output with an error: Imported legacy fsk4 Using Volk machine: ssse3_32 Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 162, in run_module_as_main "_main__", fname, loader, pkg_name) File "/usr/lib/python2...

expect script : "expect 'X', send 'Y'" until expect "Z".
Hi. I am having some difficulties with an expect script, and was hoping someone could help me out here. I am running a scripted telnet session to some 'black box' appliance, and would like to retrieve the output of a particular command. However, the output of the command is longer than a single screen full. Since it was designed for interactive use, you get the magic string "[=More (xx%)=]" after each screenfull of output, at which point the command expects you to hit the spacebar in order to get another screenfull of output. Of course, I could just "send <space&...

MS: "XP is End Of Life" Resellers(no fear): "F U MS, We're Still Sellin' It" Heh heh.
MS power is not waning. It is Dead. ONLY inertia inertia inertia inertia inertia inertia keeps them alive. ...

"""""""""ADD ME""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

Web resources about - "Run-Time Error '3012' : Object "------------" already exists - comp.databases.ms-access

Resources last updated: 3/6/2016 10:36:03 PM