Results 1 to 4 of 4
  1. #1
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24

    Question Could someone Please tell me what the proper way to type this expression is

    I have a form called Applicants. Inside the form is sub-form called InterviewReview. On that form I have an unbound text field labeled Text26. I want to update a table called INTVAnswers with the text typed into the Text26 filed. The button works when I put the applicantID in the code as whatever number it actually is. However, I am trying to get the expression to recognize the ApplicantID from the parent form and I am not having any success. Here is what I have so far. If someone could tell me what I need to do to fix this expression I would be very appreciative.



    Private Sub AddCom_Click()
    On Error GoTo AddCom_Click_Err

    Dim dbs As Database
    Set dbs = CurrentDb

    'If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = 1;"
    ' Works inserts into Com1 text26 where the applicantid = whatever number I put there in the code.

    ' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = & Forms!Applicants![ApplicantID];"
    ' Error = "Syntax error (missing operator) in query expression 'ApplicantID = & Forms!Applicants![ApplicantID]'


    ' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = '" & Forms!Applicants![ApplicantID] & "';"
    ' Error = "Data type mismatch in criteria expression"


    ' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Forms!Applicants![ApplicantID];"
    ' Error = "Too few Parameters. Expected 1."


    ' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Form!Applicants![ApplicantID];"
    ' Error = "Too few Parameters. Expected 1."


    ' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Forms.Applicants.[ApplicantID];"
    ' Error = "Too few Parameters. Expected 1."


    ' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Form.Applicants.[ApplicantID];"
    ' Error = "Too few Parameters. Expected 1."




    ' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Forms!Applicants!ApplicantID;"
    ' Error = "Too few Parameters. Expected 1."


    ' If (ID = 1) Then dbs.Execute "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = Forms.Applicants.ApplicantID;"
    ' Error = "Too few Parameters. Expected 1."


    AddCom_Click_Exit:
    Exit Sub

    AddCom_Click_Err:
    MsgBox Error$
    Resume AddCom_Click_Exit

    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    #3 was closest. Presuming the ID field is numeric, you don't want the single quotes:

    "Update INTVAnswers set Com1 = '" & Text26 & "' WHERE ApplicantID = " & Forms!Applicants![ApplicantID] & ";"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24
    OHHHHHH I have spent 2 days with at least 50 other attempts that I tried before starting to keep them logged so I could remember what I already tried. IT WORKS Thank you SOOO MUCH!

    Now if I could just figure out how to refresh the screen so that after I update the sub form it shows the new answer on the sub-form without having to go to the next answer and then come back to see what was updated.

    Again thank you.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No problem. It seems like Greek up until the point where it seems easy.

    You would requery the form to update it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Type mismatch in expression
    By valerie in forum Forms
    Replies: 1
    Last Post: 03-13-2012, 06:23 PM
  2. Type Mismatch in Expression"?
    By DeniseGearhart in forum Queries
    Replies: 4
    Last Post: 02-05-2012, 08:04 PM
  3. type mismatch in expression
    By lilg1924 in forum Database Design
    Replies: 3
    Last Post: 10-06-2010, 01:37 AM
  4. Data type mismatch in criteria expression
    By shexe in forum Queries
    Replies: 2
    Last Post: 09-01-2010, 12:47 PM
  5. Type mismatch in expression /Query
    By Brian62 in forum Queries
    Replies: 4
    Last Post: 04-22-2010, 10:00 AM

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