Results 1 to 5 of 5
  1. #1
    vgarzon is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2009
    Posts
    2

    Exclamation Show Recordset in unbound subform

    Hi,



    I think that I'm stuck in a glass of water, but I've been trying to do this for a couple of hours with no results. Maybe you can help me as I'm not an experienced VBA programmer.

    I'm trying to show the data retrieved in an ADO recordset, in an unbound subform.

    I do this to get the data in the recordset:

    Code:
         
         Dim cnLAO As ADODB.Connection
         Set cnLAO = New ADODB.Connection
        
         Dim strCon1 As String
         strCon1 = "PROVIDER=SQLOLEDB;DATA SOURCE=SERVER1C;INITIAL CATALOG=ToolXYZ;INTEGRATED SECURITY=sspi;"
         
         cnLAO.Open strCon1
        
         Dim rsEmpInfo As ADODB.Recordset
         Set rsEmpInfo = New ADODB.Recordset
        
         Dim strSP1 As String
         strSP1 = "EXEC sp_Get_Tool_User_Information NULL, NULL, NULL, NULL, NULL, 'ZONV', 'VIC', 'GAR', 'A'"
        
         rsEmpInfo.ActiveConnection = cnLAO
         rsEmpInfo.Open strSP1
    I test the results of the recordset and they work perfectly. Now, I need to show all the results in a subform, but I don't know how to do this.

    Can you please give me very specific details of how to do it?

    Thanks in advance,

    Victor

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Why the requirement the SubForm be *unbound*?

  3. #3
    vgarzon is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2009
    Posts
    2

    Subform just to display the results of the recordset

    It's just because the subform is placed in the form, for displaying purposes only.

    What I need, is to consult an external database, and show the results in that subform. I'm Using Access only as a front end. All my data is in an MS SQL Server.

    Am I ok doing things like that? It's OK to use the subforms for that purpose?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Why not create a static query and bind it to your subform?

  5. #5
    tiuliucci is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    2

    This is an old question but here is my solution

    Set your Recordset as a variable and then do the following.


    SQLs = "SELECT ..."
    Forms![Main Form]![Sub Form].Form.RecordSource = SQLs
    Forms![Main Form]![Sub Form].Form.Requery

    I use this for an unbound form. My main form includes fields for search information. Once the Search button is clicked the record source of the unbound sub form is set to an SQL statement and then requeried.

    Take care,
    Troy

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-13-2009, 03:03 AM
  2. Bound a unbound text box to the table
    By Brian62 in forum Forms
    Replies: 1
    Last Post: 11-06-2009, 11:05 AM
  3. Show all recordset in form/subform
    By Brian62 in forum Forms
    Replies: 4
    Last Post: 11-04-2009, 11:56 AM
  4. Replies: 4
    Last Post: 10-29-2008, 11:53 AM
  5. Get average of unbound textboxes.
    By markhook in forum Forms
    Replies: 8
    Last Post: 07-14-2006, 09:30 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums