Access 2003 runtime error "2147217900(80040e14)" Invalid Column Name

  • Hi ,

    Could you please help. I have an Asscees project linked to a SQL database.

    I have used these statements on multiple form, but for this specific form I get the error

    runtime error "2147217900(80040e14)"  Invalid Column Name "ZARandell" (this is the value of a combo box on my form which is updated from my environment - below is the straightforward code after I have setup the connection

    myrecordset.ActiveConnection = myconnection

    myrecordset.Open "Select ConfirmationID from [tbl_Temp_Promotional_Details] where UserName = " & Me.cmb_User, myconnection

    The value in Me.cmb_user is correct at this point,(ZaRandell)  yet the system seems to think the column name is ZARandell.

    Thank you

  • U need to surround the username text with quotes in the query.  Or else the server will think you want to use the Zarandell column... which obviously doesn't exists in this case.

     

    myrecordset.Open "Select ConfirmationID from [tbl_Temp_Promotional_Details] where UserName = '" & Me.cmb_User & "'", myconnection

  • Hi,

    Thank you so much for your help. How simple it is when one knows !!!

  • NP.

     

    Also you'll have tokeep in mind that a single quote in the user name will break the query.  To avoid this situation you have 2 options

    1 - use replace around the username like so : REPLACE(TextObject, "'", "''")

    2 - User stored procedures which accept parameters.  That way you avoid a big bunch of problems.  I'll let you look in the books online to get you started.  Start a new thread if you have new questions that you can't answer by searching this site.

     

    Good luck.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply