Results 1 to 6 of 6
  1. #1
    johnmerlino is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    97

    invalid procedure call

    This query pretty much does its best to bring back a middle initial based on the contents of two tables SJ_FinalForgotten (contains the first and last name fields to compare against summary_judgment table) and summary_judgment (which has the middle initial I want to retrieve). It works when ALL records in SJ_FinalForgotten contain a comma like so:


    Smith,John
    Smith,Ann
    Stevens,Ben

    However, if there's a space in one of them:
    Smith John

    Then the query doesn't run and a popup displays "invalid procedure call"

    This query below is what is causing the issue:

    Code:
    SELECT left([aname],InStr(1,[aname],",")-1) & " " 
         & right([aname],Len(aname)-InStr(1,[aname],",")) & " "
         & summary_judgment.middle_initial AS fullname 
    INTO SJ_FinalForgottenWithMiddle
    FROM 
      SJ_FinalForgotten INNER JOIN 
      summary_judgment ON 
        ((left(SJ_FinalForgotten.aname,InStr(1,SJ_FinalForgotten.[aname],",")-1))=summary_judgment.last_name) AND 
        ((right(SJ_FinalForgotten.aname,Len(SJ_FinalForgotten.aname)-InStr(1,SJ_FinalForgotten.[aname],","))=summary_judgment.first_name));

    Thanks for response.

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    still working on this John? that's a big project!


    Code:
    SELECT left([aname],InStr(1,[aname],",")-1) & " " 
         & right([aname],Len(aname)-InStr(1,[aname],",")) & " "
         & summary_judgment.middle_initial AS fullname 
    INTO SJ_FinalForgottenWithMiddle
    FROM 
      SJ_FinalForgotten INNER JOIN 
      summary_judgment ON 
        ((left(SJ_FinalForgotten.aname,InStr(1,SJ_FinalForgotten.[aname],",")-1))=
    
    summary_judgment.last_name) AND 
    
    
        ((right(SJ_FinalForgotten.aname,Len(SJ_FinalForgotten.aname)-
    
    InStr(1,SJ_FinalForgotten.[aname],","))
    
    =summary_judgment.first_name));
    What you might have to do John, is put an IIF() statement around the functions that are checking for the comma in the field. I don't think there is any other way around it really, primarily because you've already done so much work getting this far. for instance, this part of the query:
    Code:
    left([aname],InStr(1,[aname],",")-1) & " "
    would have to be changed to something like this:
    Code:
    left([aname],
    
    IIF(instr([aname], ",") = 0, 
    
    InStr(1,[aname]," ")-1),  
    
    InStr(1,[aname],",")-1)) & " "

  3. #3
    johnmerlino is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    97
    You mean like this (which is giving a missing operator syntax error)?

    Code:
    SELECT left([aname],
    IIF(instr([aname], ",") = 0, InStr(1,[aname]," ")-1),InStr(1,[aname],",")-1) 
    &  ", "  &
    right([aname],
    IIF(instr([aname], ",") = 0,Len(aname)-InStr(1,[aname]," "),Len(aname)-InStr(1,[aname],",")
    &  " " &
    defense_final.middle_initial AS fullname INTO FinalForgottenWithMiddle
    FROM FinalForgotten INNER JOIN defense_final ON 
    ((right(FinalForgotten.aname,IIF(instr([aname], ",") = 0,Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname]," ")),Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname],","))=defense_final.first_name)) 
    AND 
    ((left(FinalForgotten.aname,,IIF(instr([aname], ",") = 0,InStr(1,FinalForgotten.[aname]," ")-1)),InStr(1,FinalForgotten.[aname],",")-1))=defense_final.last_name);
    Thanks for response.

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    It's probably right John. Remember that my solution was not the only one, and it has to be expanded upon more than what I provided, because it doesn't catch all the possibilities. I would suggest maybe labeling your sql in another program, so you can sort it out and debug it faster.

  5. #5
    johnmerlino is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    97
    I think it just means there's a syntax error at "AS fullname INTO ":

    Code:
    SELECT left([aname],
    IIF(instr([aname], ",") = 0, InStr(1,[aname]," ")-1),InStr(1,[aname],",")-1) 
    &  ", "  &
    right([aname],
    IIF(instr([aname], ",") = 0,Len(aname)-InStr(1,[aname]," "),Len(aname)-InStr(1,[aname],",")
    &  " " &
    defense_final.middle_initial AS fullname INTO FinalForgottenWithMiddle
    FROM FinalForgotten INNER JOIN defense_final ON 
    ((right(FinalForgotten.aname,IIF(instr([aname], ",") = 0,Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname]," ")),Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname],","))=defense_final.first_name)) 
    AND 
    ((left(FinalForgotten.aname,,IIF(instr([aname], ",") = 0,InStr(1,FinalForgotten.[aname]," ")-1)),InStr(1,FinalForgotten.[aname],",")-1))=defense_final.last_name);
    There may be more errors. but I'm trying to address one at a time. Right now I'm not sure why i get syntax error at As clause.

  6. #6
    johnmerlino is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    97
    Alright I got it working. It was missing paranethesis

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help in service call Database
    By Nokia N93 in forum Access
    Replies: 12
    Last Post: 11-19-2010, 02:10 PM
  2. Invalid Use of Null!?!
    By Kipster1203 in forum Access
    Replies: 4
    Last Post: 05-13-2010, 06:09 AM
  3. Replies: 6
    Last Post: 04-24-2010, 11:12 AM
  4. how to call a sub procedure?
    By dollygg in forum Access
    Replies: 1
    Last Post: 08-18-2009, 05:10 AM
  5. Invalid Operation
    By ScottG in forum Forms
    Replies: 0
    Last Post: 11-14-2006, 02:05 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums