Solved

emory only recordset bound to a grid?

Posted on 2000-03-15
2
181 Views
Last Modified: 2011-08-18
I got the following code this morning and it is working perfectly:

  Dim r As ADODB.Recordset
   
  Set r = New ADODB.Recordset
  r.CursorLocation = adUseClient
   
  r.Fields.Append "IntegerField", adInteger
  r.Fields.Append "StringField", adVarChar, 30
  r.Fields.Append "DateField", adDate
   
  r.Open
   
  r.AddNew
  r.Fields("IntegerField").Value = 3
  r.Fields("StringField").Value = "It Works"
  r.Update
   
 
I am rather new to this so if this questions sounds silly, I apologize <g> I am able to populate the recordset but now I would like to present it to the user. I have tried setting the datasource or recordsource of a datagrid control to "r" but it rejects that. Can someone clear this up for me. I thought r was a recordset object and should be useable
0
Comment
Question by:scotts27
2 Comments
 
LVL 9

Accepted Solution

by:
samopal earned 50 total points
Comment Utility
Just add this lines

    Set DataGrid1.DataSource = r
    DataGrid1.Columns(0).DataField = r.Fields(0).Name
    DataGrid1.Columns(1).DataField = r.Fields(1).Name
    DataGrid1.Columns(2).DataField = r.Fields(2).Name
   
    DataGrid1.ReBind

HTH
0
 

Author Comment

by:scotts27
Comment Utility
Thanks! I was so close. I did not have it using the set syntax. I was just oing an assignmentt
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now