I have a frmDetail form which has, among many fields, txtSYear, txtSID, txtSQty, and txtSQty_Last.
The tblDetail has SID, SYear, and SQty, among many fields.
I want retrieve the SQty of last year from tblDetail to show in frmDetail.
For example, if txtSYear on the frmDetail is 2003 and SID is S-606, I want to retrieve SQty of 2002 from tblDetail where SID is S-606 and show it in txtSQty_Last on frmDetail.
I wrote the code in Afterupdate event of txtSYear as following, but it doesn't work.
Private Sub txtSYear_AfterUpdate()
Dim strSQL As String
strSQL = "SELECT tblDetail.SQty FROM tblDetail WHERE tblDetail.SYear =" & CInt(Me.txtSYear) - 1 & "AND tblDetail.SID=" & Me!txtSID
Me!txtSQty_Last = strSQL
End Sub
Because datatype of SYear is text, I need to use CINT to convert it to a number.
What is wrong with my code?
thanks in advance.
John
The tblDetail has SID, SYear, and SQty, among many fields.
I want retrieve the SQty of last year from tblDetail to show in frmDetail.
For example, if txtSYear on the frmDetail is 2003 and SID is S-606, I want to retrieve SQty of 2002 from tblDetail where SID is S-606 and show it in txtSQty_Last on frmDetail.
I wrote the code in Afterupdate event of txtSYear as following, but it doesn't work.
Private Sub txtSYear_AfterUpdate()
Dim strSQL As String
strSQL = "SELECT tblDetail.SQty FROM tblDetail WHERE tblDetail.SYear =" & CInt(Me.txtSYear) - 1 & "AND tblDetail.SID=" & Me!txtSID
Me!txtSQty_Last = strSQL
End Sub
Because datatype of SYear is text, I need to use CINT to convert it to a number.
What is wrong with my code?
thanks in advance.
John