Continuous Forms

A

A Newbie

I ưant to show all in Continuous Form by this code but I only get last record
only
so anybody can help me to show all record.

Thanks very much !!!

Dim db As Dao.Database
Dim rec As Dao.Recordset
Dim strSQL As String
Set db = CurrentDb()
strSQL = "SELECT tblA.A, tblA.B "
strSQL = strSQL & "FROM tblA "
strSQL = strSQL & "WHERE tblA.DEL= " & "Yes"
Set rec = db.OpenRecordset(strSQL)
i = rec.RecordCount
If i > 0 Then
rec.MoveFirst
With rec
Do Until rec.EOF
[Forms]![frmA]![txtA] = .Fields("A")
[Forms]![frmA]![txtB] = .Fields("B")
rec.MoveNext
Loop
End With
End If
rec.MoveLast
 
J

John Vinson

I ?ant to show all in Continuous Form by this code but I only get last record
only
so anybody can help me to show all record.

Ummm...

You're making something very easy into something very difficult.

Simply set the Form's Recordsource property to the query. Not a single
line of code is needed.

John W. Vinson[MVP]
 
A

Albert D.Kallal

Change you code as follows:

Dim strSQL As String
strSQL = "SELECT A, B FROM tblA WHERE DEL = Yes"
me.RecordSource = strSQL
 
Top