Results 1 to 7 of 7

Thread: MS Access Update Statement

  1. #1

    Thread Starter
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    MS Access Update Statement

    Can someone tell me why this segment does not work?

    Code:
    ' CREATE COMMAND AND SET PARAMETERS
            invCmd = New OleDbCommand("UPDATE invMain SET Description2=@desc2, Type=@type, " & _
                "Inventory=@inv, Trigger=@trig, LeadTime=@lead, Size=@size, Cartridge=@cart " & _
                "WHERE (Description1=@part)", invCon)
            invCmd.Parameters.Add("@desc2", OleDb.OleDbType.Char)
            invCmd.Parameters.Add("@type", OleDb.OleDbType.Char)
            invCmd.Parameters.Add("@inv", OleDb.OleDbType.Char)
            invCmd.Parameters.Add("@trig", OleDb.OleDbType.Char)
            invCmd.Parameters.Add("@lead", OleDb.OleDbType.Char)
            invCmd.Parameters.Add("@size", OleDb.OleDbType.Char)
            invCmd.Parameters.Add("@cart", OleDb.OleDbType.Char)
            invCmd.Parameters.Add("@part", OleDb.OleDbType.Char)
            invCmd.Parameters("@desc2").Value = "d2" & Me.uiDescriptionTextBox.Text
            invCmd.Parameters("@type").Value = "ty" & Me.uiTypeTextBox.Text
            invCmd.Parameters("@inv").Value = Me.uiOnHandTextBox.Text
            invCmd.Parameters("@trig").Value = Me.uiTriggerTextBox.Text
            invCmd.Parameters("@lead").Value = Me.uiLeadTextBox.Text
            invCmd.Parameters("@size").Value = Me.uiSizeTextBox.Text
            invCmd.Parameters("@cart").Value = Me.uiCartridgeComboBox.Text
            invCmd.Parameters("@part").Value = "d1" & Me.uiPartNumberLabel.Text

    It worked fine until I added the second and third items from the bottom. Now I am getting a message that says there is an error in the syntax of my update statement.
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: MS Access Update Statement

    Try .Value instead of .Text for the Combobox line. Just an idea.
    Tengo mas preguntas que contestas

  3. #3

    Thread Starter
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    Re: MS Access Update Statement

    A combobox does not have a .Value property.
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

  4. #4
    Lively Member
    Join Date
    Apr 2005
    Posts
    91

    Re: MS Access Update Statement

    Assign the value of the combo box to a variable and then the parameter check the value of the variable in debug mode. If it's OK then the added part
    of your update syntax is incorrect. I had similar trouble using @name with access and had to change it to ? in the Update syntax.

    Fishy

  5. #5
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: MS Access Update Statement

    Quote Originally Posted by circuits2
    A combobox does not have a .Value property.
    It does in Access 2000. Don't know about other versions.
    Tengo mas preguntas que contestas

  6. #6

    Thread Starter
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    Re: MS Access Update Statement

    I should have clarified. I am developing a VB.NET application that interfaces with an Access Database.
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

  7. #7
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: MS Access Update Statement

    You don't need brackets around your where clause so that might be causing it but I'd have expected Access to allow it.

    What values are in your various combo and text boxes? It's possible one of them contains an illegal character.

Posting Permissions

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



Click Here to Expand Forum to Full Width