I have the following code that is setting some command and text buttons based on a recordset. works great until it comes across a record with only one record, then it fails.
Code:
Set db = CurrentDb
x = 1
strprod = ("SELECT [tag#],coilid from coilT where dailyprodid=" & strpro)
Debug.Print (strprod)
Set rs = CurrentDb.OpenRecordset(strprod, dbOpenDynaset)
With rs
If Not .EOF And Not .BOF Then
.MoveLast
.MoveFirst
While (Not .EOF)
strcmd = "cmdcoil" & x
strtxt = "txt" & x
strtxtc = "txtc" & x
Me.Controls(strtxt) = rs![tag#]
Me.Controls(strcmd).Caption = rs![tag#]
Me.Controls(strtxtc) = rs!CoilID
.MoveNext
Wend
Debug.Print (x)
End If
.Close
End With
I have tried several versions of record checks but can not get it to recognize records with only one record. For a normal record the .EOF & .BOF are returning false but with one record i am getting true. record count was also no help, apparently since this is a SQL instead of table it does not return a correct recordcount. anyone have any ideals?