Private Sub btn_Next_Click()
'Creating Connection to database
Dim strSQL As String
Dim rs As DAO.Recordset
strSQL = "SELECT * FROM Tbl_Author"
Set rs = CurrentDb.OpenRecordset(strSQL)
If Not rs.BOF And Not rs.EOF Then
While (Not rs.EOF)
Me.txtID = rs.Fields("Author_id")
Me.txtFName = rs.Fields("AFirst_Name")
Me.txtLName = rs.Fields("ALast_Name")
Me.txtAddress = rs.Fields("Address")
Me.txtEAddress = rs.Fields("Email_Address")
Me.txtMNum = rs.Fields("Mobile_Number")
Me.txtPNum = rs.Fields("Phone_Number")
Me.cmbStatus = rs.Fields("Status")
rs.MoveNext
Wend
End If
rs.Close
End Sub
答案 0 :(得分:0)
找到答案。我根据表单中显示的当前记录编写查询,然后不需要循环,每次单击下一步,它从数据库中获取下一个值并将其发布到文本框中。