Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    123

    Angry Unanswered: Parameters shmamaters

    Why do I keep getting the error "Too few parameters. Expected 1." when I paste the SQL from Query Design directly into a VBA code? I am trying to retrieve a record based on the input of a text box.

    SELECT ECR_ADMIN_USER.*, ECR_ADMIN_USER.I_USER_ID
    FROM ECR_ADMIN_USER
    WHERE (((ECR_ADMIN_USER.I_USER_ID)=[Forms]![frmLOGINCHG]![txtUser]));

    Too many parantheses for Access's liking?

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    your parenthesis count is correct.

    i guess you are pasting into a string (e.g. strSQL) so you actually have
    Code:
    strSQL = "SELECT ECR_ADMIN_USER.*, ECR_ADMIN_USER.I_USER_ID FROM ECR_ADMIN_USER "
    strSQL = strSQL & "WHERE (((ECR_ADMIN_USER.I_USER_ID)=[Forms]![frmLOGINCHG]![txtUser]));"
    so, in effect, you are trying to match your _USER_ID to the literal string "[Forms]![frmLOGINCHG]![txtUser]" ...which is probably not what you want!!!

    try:
    Code:
    strSQL = strSQL & "WHERE (((ECR_ADMIN_USER.I_USER_ID)='" &[Forms]![frmLOGINCHG]![txtUser] & "'));"
    izy

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    As a side note, you can simplify your query (always desirable when manipulating SLQ text!) by not calling ECR_ADMIN_USER.I_USER_ID when it already being returned as part of ECR_ADMIN_USER.*:

    SELECT ECR_ADMIN_USER.*
    FROM ECR_ADMIN_USER
    WHERE I_USER_ID=[Forms]![frmLOGINCHG]![txtUser];

    Neither do you need all those confusing parenthesis, which the query designer automatically includes 'cause it keeps track of them easily while we mortals get confused.

    Then, if izyrider's answer doesn't solve your problem, can we assume that ECR_ADMIN_USER is a table (not a stored query) and that frmLOGINCHG is open? Is your code in a global module or a form module?

    blindman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •