Ahh, okay. Thanks John. I don't get the error anymore, but it doesn't actually change the value if the status field to A for those tickets. Very weird.
And ticket is a numeric field FYI.
Here is what the code looks like now:
Private Sub commandVoid_Click()
Dim strSQL As String
If MsgBox("Are you sure you want to void this ticket?", vbYesNo) = vbYes Then
strSQL = "UPDATE tableWarehouseData " & _
"SET Status = '" & V & "' " & _
"WHERE Ticket = " & Me.comboVoidTicket
End If
End Sub
--- In MS_Access_Professionals@yahoogroups.com, John Viescas <JohnV@...> wrote:
>
> Tony-
>
> Your quotes are all messed up. Try this:
>
> strSQL = "UPDATE tableWarehouseData " & _
> "SET Status = '" & V & "' " & _
> "WHERE ticket = '" & Me.comboVoidTicket & "'"
>
>
> That assumes that ticket is a text field. If not, then do:
>
> strSQL = "UPDATE tableWarehouseData " & _
> "SET Status = '" & V & "' " & _
> "WHERE ticket = " & Me.comboVoidTicket
>
> John Viescas, Author
> Microsoft Access 2010 Inside Out
> Microsoft Access 2007 Inside Out
> Microsoft Access 2003 Inside Out
> Building Microsoft Access Applications
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
>
>
>
>
>
> -----Original Message-----
> From: Gkillah36 <GKillah36@...>
> Reply-To: <MS_Access_Professionals@yahoogroups.com>
> Date: Friday, November 30, 2012 6:17 AM
> To: <MS_Access_Professionals@yahoogroups.com>
> Subject: Re: [MS_AccessPros] Using UPDATE to change data in a table via
> combobox and command button
>
> V just comes from me. I just want to have all of the Status field values
> change to V for the ticket that the user selects. The Status field is
> text.
>
> Thanks,
> Tony
>
>
>
>
>
>
>
> -----Original Message-----
> From: Duane Hookom <duanehookom@...>
> To: Access Professionals Yahoo Group
> <ms_access_professionals@yahoogroups.com>
> Sent: Fri, Nov 30, 2012 12:15 am
> Subject: RE: [MS_AccessPros] Using UPDATE to change data in a table via
> combobox and command button
>
>
>
>
>
> Where does V come from? Is the Status field text or numeric?
>
> Learn how to implement
> Debug.Print strSQL
> So you can troubleshoot on your own.
>
> Duane Hookom MVP
> MS Access
>
> > From: GKillah36@...
> >
> > Hi all,
> >
> > Please see my VB below:
> >
> > Private Sub commandVoid_Click()
> >
> > Dim strSQL As String
> >
> > If MsgBox("Are you sure you want to void this ticket?", vbYesNo) = vbYes
> >Then
> > strSQL = "UPDATE tableWarehouseData " & _
> > "SET Status = " & V & " " & _
> > "WHERE ticket = " & Me.comboVoidTicket & ""
> > CurrentDb.Execute strSQL, dbFailOnError
> > End If
> > End Sub
> >
> >
> > ----------------------------------------
> >
> > This should change the Status field of all tickets in the table
> >tableWarehouseData to V when clicked based on the selected ticket number
> >in the comboVoidTicket combobox. However, I'm getting an error of
> >"Run-time error '3144': Syntax error in UPDATE statement." What am I
> >missing here?
> >
> > Thank you,
> > Tony
> >
> > FYI, I'm using Access 2010.
>
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (5) |
Tidak ada komentar:
Posting Komentar