Solved SELECT Statement (1 Viewer)

Momma

Member
Local time
Tomorrow, 08:23
Joined
Jan 22, 2022
Messages
114
I assume something is wrong with my second Where condition in the Select Statement. It works when I run it with only the first Where condition.
Can someone help me with this, please?

Code:
Private Sub Price_AfterUpdate()

On Error GoTo ErrorHandler

If Me.CboBuyer > 0 Then

Dim CurrentPrice As Currency
CurrentPrice = Forms!frmpuppybuyerlist.Form!frmPuppyBuyerlistsubf.Form!Price
Dim CurrentInvoiceID As Long
CurrentInvoiceID = Forms!frmpuppybuyerlist.Form!frmPuppyBuyerlistsubf.Form!frmInvoice!InvoiceID
Dim SQL As String
SQL = "SELECT [InvoiceID], [Description], [Amount] from [tblInvoiceDetails] WHERE InvoiceID=" & CurrentInvoiceID And [Description] Like "Puppy"
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset(SQL)

With rs
    If Not .BOF And Not .EOF Then
        .MoveLast
        .MoveFirst
        If .Updatable Then
            .Edit
            ![Amount] = CurrentPrice
            .Update
        End If
    End If
    
    .Close
End With
Me.Requery

Exitsub:
    Set rs = Nothing
    Exit Sub
    
End If


ErrorHandler:
    Resume Exitsub

End Sub
 

bob fitz

AWF VIP
Local time
Today, 23:23
Joined
May 23, 2011
Messages
4,726
Perhaps:
WHERE InvoiceID=" & CurrentInvoiceID & " AND [Description] =""Puppy"""
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:23
Joined
May 7, 2009
Messages
19,246
or maybe:

SQL = "SELECT [InvoiceID], [Description], [Amount] from [tblInvoiceDetails] WHERE InvoiceID=" & CurrentInvoiceID & " And [Description] Like 'Puppy'"
 

Momma

Member
Local time
Tomorrow, 08:23
Joined
Jan 22, 2022
Messages
114
Thank you Bob and Arnel, both of your suggestions are successful. I really appreciate this forum and these guys who are so generous.
Thank you, thank you!!
 

Users who are viewing this thread

Top Bottom