Solved

emory only recordset bound to a grid?

Posted on 2000-03-15
2
189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
samopal earned 50 total points
ID: 2621333
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
ID: 2621350
Thanks! I was so close. I did not have it using the set syntax. I was just oing an assignmentt
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

632 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