This query does not run at the beginning. Could someone please help look at what is wrong? This query does not run at the beginning. Could someone please help look at what is wrong? What I have tried: <pre> strSQL1 = "SELECT * FROM PharmSales WHERE HospitalNo='" & Me.txtRegNo & "' And TDate = #" & Format(Me.txtTDate, "M\/dd\/yyyy") & "# AND SalesItem1 = '" & Me.txtSalesItem1 & "' And PharmSalesID= (SELECT MAX(PharmSalesID) FROM PharmSales)" Set pr = db.OpenRecordset(strSQL1) With pr If Not .BOF And Not .EOF Then 'Ensure that the recordset contains records .MoveLast .MoveFirst If .Updatable Then 'To ensure record is not locked by another user .Edit 'Must start an update with the edit statement If IsNull(![TotalPaid]) = True And Me.txtGrand_TotalPay.Value >= Me.txtSalesAmt1.Value Then ![DispQty1] = Nz(![DispQty1] + Me.txtSalesQty1.Value, 0) .Update ElseIf IsNull(![TotalPaid]) = False And (Me.txtGrand_TotalPay.Value - Me.txtSalesAmt1.Value) >= (txtGrand_TotalFee - Me.txtGrand_TotalPay.Value + Me.txtSalesAmt1.Value) Then ![DispQty1] = Nz(![DispQty1] + Me.txtSalesQty1.Value, 0) .Update Else: MsgBox ("Insufficient balance!") End If End If End If pr.Close Set pr = Nothing Set db = Nothing End With End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)