WordTechinc
Programmer
- Sep 4, 2009
- 38
I want to select record which FaceLetter = false only from table. FaceLetter is Yes/No field. When I run execute code I get all record from input table.
Here is code;
Private Sub CreateTaxCertification_Click()
Dim db As Database
Dim rs As Recordset ''' record write '''
Dim rs2009 As Recordset ''' record from here '''
Dim X As Variant
Set db = CurrentDb()
''' Select FaceLetter(Yes/No) false only '''
Set rs = db.OpenRecordset("TaxCertification")
Set rs2009 = db.OpenRecordset("Select * from RETX-2009 WHERE FaceLetter = 0")
''' function if there are FaceLetter = false records '''
X = rs2009.RecordCount
If X > 0 Then
''' it will go thru end of record and come back to first record '''
rs2009.MoveLast
rs2009.MoveFirst
Do While Not rs2009.EOF
rs.AddNew
rs.Fields("Parid") = rs2009.Fields("Parid").Value
rs.Fields("YearCur1FaceAmt").Value = rs2009.Fields("FaceAmount").Value
rs.Fields("YearCur1Status").Value = rs2009.Fields("FaceStatus").Value
rs.Fields("Legal 1") = rs2009.Fields("Legal 1").Value
rs.Fields("Legal 2") = rs2009.Fields("Legal 2").Value
rs.Fields("Own 1") = rs2009.Fields("Own 1").Value
rs.Fields("Own 2") = rs2009.Fields("Own 2").Value
rs.Fields("Address 1") = rs2009.Fields("Address 1").Value
rs.Fields("Address 2") = rs2009.Fields("Address 2").Value
rs.Fields("City") = rs2009.Fields("city").Value
rs.Fields("St") = rs2009.Fields("St").Value
rs.Fields("Zip") = rs2009.Fields("Zip").Value
rs.Fields("Apr Land") = rs2009.Fields("Apr Land").Value
rs.Fields("Apr Bldg") = rs2009.Fields("apr Bldg").Value
rs.Fields("Asmt Total") = rs2009.Fields("Asmt Total").Value
rs.Update ''' WRITE into new table '''
rs2009.MoveNext ''' read next input record '''
Loop
End If
Set db = Nothing
Set rs = Nothing
Set rs2009 = Nothing
Set rs2008 = Nothing
End Sub
Here is code;
Private Sub CreateTaxCertification_Click()
Dim db As Database
Dim rs As Recordset ''' record write '''
Dim rs2009 As Recordset ''' record from here '''
Dim X As Variant
Set db = CurrentDb()
''' Select FaceLetter(Yes/No) false only '''
Set rs = db.OpenRecordset("TaxCertification")
Set rs2009 = db.OpenRecordset("Select * from RETX-2009 WHERE FaceLetter = 0")
''' function if there are FaceLetter = false records '''
X = rs2009.RecordCount
If X > 0 Then
''' it will go thru end of record and come back to first record '''
rs2009.MoveLast
rs2009.MoveFirst
Do While Not rs2009.EOF
rs.AddNew
rs.Fields("Parid") = rs2009.Fields("Parid").Value
rs.Fields("YearCur1FaceAmt").Value = rs2009.Fields("FaceAmount").Value
rs.Fields("YearCur1Status").Value = rs2009.Fields("FaceStatus").Value
rs.Fields("Legal 1") = rs2009.Fields("Legal 1").Value
rs.Fields("Legal 2") = rs2009.Fields("Legal 2").Value
rs.Fields("Own 1") = rs2009.Fields("Own 1").Value
rs.Fields("Own 2") = rs2009.Fields("Own 2").Value
rs.Fields("Address 1") = rs2009.Fields("Address 1").Value
rs.Fields("Address 2") = rs2009.Fields("Address 2").Value
rs.Fields("City") = rs2009.Fields("city").Value
rs.Fields("St") = rs2009.Fields("St").Value
rs.Fields("Zip") = rs2009.Fields("Zip").Value
rs.Fields("Apr Land") = rs2009.Fields("Apr Land").Value
rs.Fields("Apr Bldg") = rs2009.Fields("apr Bldg").Value
rs.Fields("Asmt Total") = rs2009.Fields("Asmt Total").Value
rs.Update ''' WRITE into new table '''
rs2009.MoveNext ''' read next input record '''
Loop
End If
Set db = Nothing
Set rs = Nothing
Set rs2009 = Nothing
Set rs2008 = Nothing
End Sub