Hi everybody
I thank mr john and others for helping me in the last post.
Once again i am here to disturb u.
Can you help to solve this issue
i have a form which contains the item details for the particular period.it has a field called opening balance which fetches the closing qty from the previous entry.i face problem while editing the previous record because it takes last closing qty.
the code is as follows
Private Sub openingbalance_GotFocus()
Call test
End Sub
Private Sub test()
Dim sql As String
Dim con As DAO.Connection
Dim rs As DAO.Recordset
Dim st, fm, itemid As Integer
Dim lfm, qty As Double
Dim dateto As Date
itemid = Forms!smptest![Partyname]
dateto = Forms!smptest!dateto
sql = "SELECT t1.Partyname, t1.Closingqty AS closing,t1.dateto as dateto FROM t1 WHERE (((t1.Partyname) = " & itemid & "))GROUP BY t1.Partyname, t1.Closingqty,t1.dateto having (t1.dateto<" & dateto & ")"
Set rs = CurrentDb.OpenRecordset(sql)
'Do While Not rs.EOF
If rs.RecordCount > 0 Then
rs.MoveLast
lfm = rs("closing")
Forms!smptest!openingbalance.SetFocus
'MsgBox lfm
Forms!smptest!openingbalance = lfm
Else
Forms!smptest!openingbalance.SetFocus
Forms!smptest!openingbalance = 0
'End If
'rs.MoveNext
'st = "TripReport"
'Loop
'DoCmd.OpenReport st
'
'Loop
End If
End Sub
i want to compare the date how can i do this?
Thanks in advance
I thank mr john and others for helping me in the last post.
Once again i am here to disturb u.
Can you help to solve this issue
i have a form which contains the item details for the particular period.it has a field called opening balance which fetches the closing qty from the previous entry.i face problem while editing the previous record because it takes last closing qty.
the code is as follows
Private Sub openingbalance_GotFocus()
Call test
End Sub
Private Sub test()
Dim sql As String
Dim con As DAO.Connection
Dim rs As DAO.Recordset
Dim st, fm, itemid As Integer
Dim lfm, qty As Double
Dim dateto As Date
itemid = Forms!smptest![Partyname]
dateto = Forms!smptest!dateto
sql = "SELECT t1.Partyname, t1.Closingqty AS closing,t1.dateto as dateto FROM t1 WHERE (((t1.Partyname) = " & itemid & "))GROUP BY t1.Partyname, t1.Closingqty,t1.dateto having (t1.dateto<" & dateto & ")"
Set rs = CurrentDb.OpenRecordset(sql)
'Do While Not rs.EOF
If rs.RecordCount > 0 Then
rs.MoveLast
lfm = rs("closing")
Forms!smptest!openingbalance.SetFocus
'MsgBox lfm
Forms!smptest!openingbalance = lfm
Else
Forms!smptest!openingbalance.SetFocus
Forms!smptest!openingbalance = 0
'End If
'rs.MoveNext
'st = "TripReport"
'Loop
'DoCmd.OpenReport st
'
'Loop
End If
End Sub
i want to compare the date how can i do this?
Thanks in advance