Results 1 to 5 of 5

Thread: Access 2000 ADO and Subform Population

  1. #1

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393
    Hi gang,

    I've been banging my head against my desk for around 6 hours trying to figure this out.

    I'm using 2 databases. One has all data (data.mdb) and the other has the GUI stuff in it(GUI.mdb).

    I'm doing it this way because we want to make the data as secured as possible.

    Anyway, I would like to open a recordset in ADO and then show the results in a subform.


    This is my current code.

    Code:
    Dim cnn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sSQL As String
            
    
        Set cnn = New ADODB.Connection
        Set rs = New ADODB.Recordset
    
        With cnn
            .ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & "DBQ=D:\DATA.mdb;"
            .Open
        End With
        'COMPANY_LIST is the table
        sSQL = "SELECT * FROM COMPANY_LIST"
        Set rs = cnn.Execute(sSQL)
            
        cnn.Close
    
    set cnn = nothing
    set rs = nothing
    Can this be done?



    Also,

    I got it working to populate a combo box. But it comes back and says that it can only accept 2,??? characters.

    What is the correct way to do this?


    Please forgive my dumb questions, but database stuff is really new to me.

    Help Please!!!



    Thanks,
    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  2. #2
    Addicted Member ShIzO's Avatar
    Join Date
    Apr 1999
    Location
    Bartlett, IL
    Posts
    189
    who comes back and tell you to use 2 charactes? is it a runtime error or AccessDB error and at which point do you get that message?
    www.HardFind.com -buy/sell/trade your used hardware.

  3. #3

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Smile

    Hi,
    Thanks for the reply. When I'm populating the combo box, I do a loop and add a ";" at the end of result in the field I want. If I try and let it add all the content from the that field in the table, then Access comes back and says that "can not accept a value over 2,480 characters.

    I deleted the code in frustration.

    The way you can populate a combo box in Access really stinks because for every value you want to put in the box, you need a ";".
    Example,
    "name1;name2;name3;name4;etc..."

    You can't just do an additem like in standalone VB.

    There is another way to populate a Combo Box by assigning it to a table or query, but I don't think I can do that trying to get records from an outside database.

    Thanks for whatever help I can get.

    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  4. #4
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Horst
    Posts
    262
    Hi there,

    About the sub form stuff I-dun-no, I am a VB starter. Access I do know.

    A tip for the combobox: instead of adding the values manualy you can use a table.

    e.g. SELECT orderid FROM ORDER (or whatever)

    About the subform:
    In ACCESS(!) I always use a query (or SQL-statement) as the source for a sub-form.

    So if you're main(vb)-form uses a SQL-statement as source why not use a different SQL-statement as source for the subform?


    I studied you're code. I think that the code works. However I do not see any code where DISPLAYS the result.

    Sander

    PS: I was just brainstorming in my own creepy mind so dont attack me

  5. #5

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Talking Thanks Sander

    Hi,

    Thanks for the input.

    In other Access programs, I have used queries as the source of a subform. The thing is that all the data was in the same database. This is my first time trying to get records from an outside database. It's kinda like if someone wanted to get data from and Oracle or Sql Server database.

    Pretty much what you told me I understand and have inplemented it in the past.

    The code works, but what I need is a way to display the results. I would like to do that with a subform.

    I don't know how to link the subform to a ADO query. Your example is basically what I want to do, but I don't know how to get a ADO query to work with it.

    Thanks again,
    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width