Delete in table from input box

dimanche 1 mars 2015

I'm having trouble executing a SQL command in VB... I want it to find the the value of the input box in TBL-Purchases and Delete all related values. Here's my code.... I get an error on the line I've highlighted in green... Any thoughts?





Private Sub Command31_Click()

Dim Message, Title, Default, MyValue1, MyValue2

Title = "Sell Stocks"

Default = ""

MyValue1 = InputBox("Which stock ticker name would you like to sell?")

MyValue1 = UCase(MyValue1)

If MyValue1 = Empty Then Exit Sub

If MsgBox(MyValue1 & "?", vbQuestion + vbYesNo) = vbYes Then

MyValue2 = InputBox("How many shares would you like to sell?")

If MsgBox(MyValue2 & "?", vbQuestion + vbYesNo) = vbYes Then

MsgBox ("You have chosen to sell " & MyValue2 & " shares of " & MyValue1 & ".")



DoCmd.RunSQL "DELETE * FROM TBL-Purchases WHERE [Stock ID] = MyValue1"



Else: MsgBox ("You did not enter an appropriate value.")

End If

End If





End Sub

Delete in table from input box

0 commentaires:

Enregistrer un commentaire

Labels