0

I keep recieving compiling errors saying that txtlln in the where line cannot be found. I am fairly new to SQL/VBA so I am not sure I am using the correct expressions to have this work.

Private Sub btnlledit_Click()
Dim strSQL As String
SQL = "UPDATE tblll " & _
      "SET [Component/Product] = '" & Forms!frmaddll!txtllcomponent & "',[HN] = '" & Forms!frmaddll!txtllhn & "' " & _          
      "WHERE [LLN] = '" & Forms!frmaddll!txtlln.value & "';"
debug.print sql
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
DoCmd.Requery

Me.Refresh 
End Sub
3
  • Can you try to add a .Value to the end of Forms!frmaddll!txtlln? Commented Jul 14, 2018 at 21:16
  • added .value now I recieve the error Sub or Function not defined for Where LLN = Forms!frmaddll!txtlln.Value Commented Jul 14, 2018 at 21:39
  • You seem to be using & "" instead of & "' in your string concatenation. Commented Jul 14, 2018 at 21:49

1 Answer 1

2

You seem to have a few issues swith your string concatenation.

Private Sub btnlledit_Click()
    Dim strSQL As String

    SQL = "UPDATE tblll " & _
          "SET [Component/Product] = '" & Forms!frmaddll!txtllcomponent & "' " & _
          "WHERE [LLN] = '" & Forms!frmaddll!txtlln.value & "';"
    debug.print sql
    DoCmd.RunSQL strSQL
    DoCmd.SetWarnings True
    DoCmd.Requery

    Me.Refresh

End Sub
Sign up to request clarification or add additional context in comments.

5 Comments

what does the debug.print sql do? I haven't inputted the code yet because I went home and I am going to try it tomorrow.
btw, it's pronounced 'kuh-ool' to the best of my knowledge.
That code works great, however I tried to copy/past set for other lines of input because of have multiple things to update and put in difference places from the form for the table to use and I am getting syntax errors.
nvm, i figured it out for the multiple updates! Thank you for the sub.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.