Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2011
    Posts
    413

    Unanswered: Update Table Via Text Box

    Can't see the forest because of the trees!
    txtcomputer is unbound text box on form
    fldComputer is Computer Name field in tblUserSecurity
    txtUserID is the User Name
    EmpName is User Name is tblUserSecurity

    'UPDATE COMPUTER NAME

    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE tblUserSecurity SET tblUserSecurity.fldComputer = Me.txtcomputer.Value " & _
    "WHERE (((tblUserSecurity.EmpName)='" & Me.txtUserID.Value & "'));"
    DoCmd.SetWarnings True

    It asks me for the fldComputer ???

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if its asking for 'fldComputer', then you cannot have a column called fldComputer in table tblUserSecurity

    check spelling
    if it does exist then it could be throwing a wobbler if fldComputer is string/text, in which case you must delimit the Me.txtcomputer.Value

    when you put a breakpoint on the code does the update statement look correct ie valid SQL. debugging SQL is ALWAYS easier if you assign the value of the SQL to a variable first and then use that variable later on eg:-

    Code:
    strSQL = "UPDATE tblUserSecurity SET tblUserSecurity.fldComputer = Me.txtcomputer.Value " & _
    "WHERE (((tblUserSecurity.EmpName)='" & Me.txtUserID.Value & "'));"
    DoCmd.RunSQL strSQL
    until you have debugged the code turning 'warnigns off' is not a smart call.. you are probably suppressing the error message and making debugging trickier than it needs be


    ...of course it could be that your SQL is at fault and because you have turned off warnings....
    Last edited by healdem; 07-19-14 at 17:05.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Nov 2011
    Posts
    413
    Adjusted code, this worked.
    DoCmd.RunSQL "UPDATE tblUserSecurity SET tblUserSecurity.fldComputer = txtcomputer.Value " & _

    Thanks,

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    are you certain on that?

    I could believe....
    Code:
    DoCmd.RunSQL "UPDATE tblUserSecurity SET tblUserSecurity.fldComputer = " & txtcomputer.Value  & _
    assuming that fldComputer is numeric
    if it was string/text
    Code:
    DoCmd.RunSQL "UPDATE tblUserSecurity SET tblUserSecurity.fldComputer = '" & txtcomputer.Value  & "'" & _
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Nov 2011
    Posts
    413
    YES. fldComputer is Text. It works.

    Many Thanks,

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
  •