In preceeding code I successfully get a record from SQL server, and I want to see if the contents of any column in the recordset is Null, Zero Length. I want to loop through the fields in the recordset (rsdbo). There is data in the recordset, I've checked that, but the loop bombs with eithet "Next without For", or "Else without If", depending on the order. The "If Trim" statement was supplied by MajP (and there is another try commented out), but I suspect that the problem might be there, or there is something about For Loops and Ifs I don't understand.
If there is no data in the record set I want to do nothing. But if there is data I want to publish a message box alerting the data entry person that data already exists.
Sounds simple enough, but my my, I can't get it to work.
'See if data already entered
Dim I As Integer
I = 0
rsdbo.MoveFirst 'Position cursor on first record
'In rsdbo recordset
'Start Loop on Last_Name column in rsdbo recordset
For I = 0 To 9
'If Len(rsdbo.Fields(I).Value & "") = 0 Then
If Trim(rsdbo.Fields(I).Value & " ") = "" Then 'If Null or Zero Length
MsgBox "Null or Zero"
Next
Else
End If
MsgBox "Data Already Entered"
Me.Last_Name.SetFocus
Thanks in advance
jpl
If there is no data in the record set I want to do nothing. But if there is data I want to publish a message box alerting the data entry person that data already exists.
Sounds simple enough, but my my, I can't get it to work.
'See if data already entered
Dim I As Integer
I = 0
rsdbo.MoveFirst 'Position cursor on first record
'In rsdbo recordset
'Start Loop on Last_Name column in rsdbo recordset
For I = 0 To 9
'If Len(rsdbo.Fields(I).Value & "") = 0 Then
If Trim(rsdbo.Fields(I).Value & " ") = "" Then 'If Null or Zero Length
MsgBox "Null or Zero"
Next
Else
End If
MsgBox "Data Already Entered"
Me.Last_Name.SetFocus
Thanks in advance
jpl