Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a table

Status
Not open for further replies.

shaz123

Technical User
Oct 13, 2006
60
DE
I have the following SQL statements, when testing them they do bring back the correct information however they are not updatng the fields wihtin the tabl. The command button updating the table si based on the information being viewed fomr a listbox. i have also locked the listbox, so the individual does not need to select a particular order from there.

Code:
If MsgBox("Click Yes if this is a Onsite Delivery, Else click on No for Customer Collection", vbYesNo + vbQuestion) = vbYes Then
            Me.Person.SetFocus
            Sql = "UPDATE [tbl_Delupdate] SET "
            Sql = Sql & "[CustomerCollection/OnsiteDelivery] = 'OD' "
            Sql = Sql & "WHERE [Time of Transaction] = #" & datMaxDate & "# "
            Sql = Sql & "AND [Cylinder Barcode Label] = '" & stringy1 & "' "
            Sql = Sql & "AND [Works Order Number] = '" & Me.Person.Text & "' "
            db.Execute (Sql)
            MsgBox Sql
            Debug.Print Sql
       Else
            Me.Person.SetFocus
            Sql = "UPDATE [tbl_Delupdate] SET "
            Sql = Sql & "[CustomerCollection/OnsiteDelivery] = 'CC' "
            Sql = Sql & "WHERE [Time of Transaction] = #" & datMaxDate & "# "
            Sql = Sql & "AND [Cylinder Barcode Label] = '" & stringy1 & "' "
            Sql = Sql & "AND [Works Order Number] = '" & Me.Person.Text & "' "
            db.Execute (Sql)
            Debug.Print Sql
            MsgBox Sql
        End If
 
        If StrPtr(stringy1) <> 0 Then
        Me.Person.SetFocus
            Sql = "Update [tbl_Delupdate] SET "
            Sql = Sql & "[Date of D Status] = '" & Stringy2 & "', "
            Sql = Sql & "[D Status] = 'Delivered' "
            Sql = Sql & "WHERE [Time of Transaction] = #" & datMaxDate & "# "
            Sql = Sql & "AND [Cylinder Barcode Label] = '" & stringy1 & "' "
            Sql = Sql & "AND [Works Order Number] = '" & Me.Person.Text & "' "
            
            MsgBox Sql
            Debug.Print Sql
            db.Execute (Sql)
            
            MsgBox "Selected items have been marked as delivered for date " & Stringy2, vbInformation, "Items Delivered Successfully"
        Else
            Exit Sub
        End If
    End If
 
shaz123 . . .

In [blue]query design[/blue] view make the same update query then switch to [blue]SQL View[/blue] to see where your going wrong!

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top