Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Next without For error

Status
Not open for further replies.

daklem

Technical User
Sep 28, 2003
23
0
0
Hi,

I have the following code in an on click event to check if all the fields in a query have data. A message box displays which fields are missing data. I continue to get a "Next withot For" error when this code runs. Any suggestions?

Private Sub cmdQueryTest_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Integer
Dim str As String

Set db = CurrentDb()
Set rs = db.OpenRecordset("qryFormLetter",dbOpenDynaset)
rs.FindFirst "[tblPatients_PtID]=" & Me.txtPtID

str = ""
For i = 0 To rs.Fields.Count - 1
If IsNull(rs(i).Value) Then
str = str & rs(i).Name & vbCr
Next i

MsgBox "The following fields are missing data:" & vbCr _
& str

rs.Close

End Sub

Thanks
 
I figured it out.

I forgot the "End If" before the "Next i"

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top