"DisplayFields" trouble

jessa_lee

Registered User.
Local time
Today, 06:22
Joined
Oct 14, 2003
Messages
40
New problem. I'm trying to display the fields & field info (not records) within my table, but when I run it, I get the error message "Run-time error '3021': Either BOF or EOF is true, or the current record has been deleted. Requested operation requires a current record." See following:

Sub DisplayFields()
Dim Connection As New ADODB.Connection
Dim Catalog As New ADOX.Catalog
Dim RecordSet As New ADODB.RecordSet
Dim Field As Field

Connection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\mis34jc\Desktop\contacts.mdb"
Set Catalog.ActiveConnection = Connection
RecordSet.Open "SELECT * FROM CONTACTS", Catalog.ActiveConnection, adOpenKeyset
RecordSet.Fields.Refresh
For Each Field In RecordSet.Fields
Debug.Print Field.Name & ", " & Field.Type & ", " '& Field.ActualSize
Next
RecordSet.Close
Set RecordSet = Nothing
Set Catalog = Nothing
Connection.Close
Set Connection = Nothing
End Sub
 
Ha! It seems all I need to do is post in here and I find my answer. The manual I'm learning from is WRONG! The "Field.ActualSize" should have been set to "Field.DefinedSize". You know? I'm so sick of correcting user's manuals. Maybe I should go into business as an editor. :P
 
What book is that from? I'll know to avoid it. :p
 
Sadly, it's from the "Sam's Teach Yourself" series - it's the Microsoft Access 2000 Programming in 24 hours book.

Although, I suppose I am "teaching myself" by figuring out their mistakes to get their examples to work! Ha! ;)

Thanks for your help :)
 

Users who are viewing this thread

Back
Top Bottom