Adodc1.Recordset.Find ("名稱="" & mno & """)如果沒有找到,此時,Adodc1.Recordset.EOF將為TRUE,此時只能前移MovePrevious或MoveFirst或MoveLast,不能再MoveNext,即只能move 一個負值,而不能move一個正值。如果再繼續move p,將出錯,已經到最後一條的後面了執行以下程式碼可使Adodc1.Recordset.EOF為TRUE: Adodc1.Recordset.MoveLast Adodc1.Recordset.MoveNext Private Sub Command9_Click()Dim mno As String, p%p = Adodc1.Recordset.AbsolutePositionmno = InputBox("請輸入名稱", "查詢窗")Adodc1.RefreshAdodc1.Recordset.Find ("名稱="" & mno & """)If Trim(mno) = "" Then"應把此判斷提到前面Adodc1.Recordset.AbsolutePosition = pValue = MsgBox("沒有找到記錄!", 0, "提示")ElseIf Text1.Text = "" ThenAdodc1.Recordset.AbsolutePosition = pValue = MsgBox("沒有找到記錄!", 0, "提示")Me.RefreshEnd If可用Bookmark代替AbsolutePositionEnd Sub
Adodc1.Recordset.Find ("名稱="" & mno & """)如果沒有找到,此時,Adodc1.Recordset.EOF將為TRUE,此時只能前移MovePrevious或MoveFirst或MoveLast,不能再MoveNext,即只能move 一個負值,而不能move一個正值。如果再繼續move p,將出錯,已經到最後一條的後面了執行以下程式碼可使Adodc1.Recordset.EOF為TRUE: Adodc1.Recordset.MoveLast Adodc1.Recordset.MoveNext Private Sub Command9_Click()Dim mno As String, p%p = Adodc1.Recordset.AbsolutePositionmno = InputBox("請輸入名稱", "查詢窗")Adodc1.RefreshAdodc1.Recordset.Find ("名稱="" & mno & """)If Trim(mno) = "" Then"應把此判斷提到前面Adodc1.Recordset.AbsolutePosition = pValue = MsgBox("沒有找到記錄!", 0, "提示")ElseIf Text1.Text = "" ThenAdodc1.Recordset.AbsolutePosition = pValue = MsgBox("沒有找到記錄!", 0, "提示")Me.RefreshEnd If可用Bookmark代替AbsolutePositionEnd Sub