Results 1 to 4 of 4

Thread: Adodc Recordsource (HELP)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2018

    Exclamation Adodc Recordsource (HELP)

    good day everyone!

    So i made a program that creates a table using a name from textbox and it worked now the problem is in another form where i have a datagrid and a textbox again to show the records that i wanna see in data grid

    heres what the forms looks like Name:  form4.jpg
Views: 66
Size:  25.6 KB

    it worked and it shows the data in datagrid but there is a popup Name:  problem.png
Views: 57
Size:  2.8 KB

    and this whats inside my adodc Name:  adodc.png
Views: 56
Size:  6.8 KB

    and heres my code for the entire form (Remember theres nothing wrong with code below the only problem is the code for "Command Text(SQL)

    Dim con As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim sql As String
    Dim display As String

    Private Sub Command1_Click()

    display = Text1.Text & Space(1) & Text2.Text & Space(1) & Text3.Text

    '‘define SQL query
    sql = "Select * from [" & display & "]"
    '‘specify format of SQL result and assisgn to ADODC
    adogrid.CommandType = adCmdText
    adogrid.RecordSource = sql
    '‘Display result in the datagrid object
    Set DataGrid1.DataSource = adogrid

    End Sub

    I hope and I wish someone could help me resolve this problem, thank you!!

  2. #2
    Join Date
    Feb 2012
    West Virginia

    Re: Adodc Recordsource (HELP)

    You show two different sql statements the one in the window is not valid then one in code looks to be ok assuming that display is a string variable that holds the name of a table. If it is an empty var then that too would be invalid

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2018

    Re: Adodc Recordsource (HELP)


    so what should i do?

  4. #4
    Fanatic Member
    Join Date
    Jan 2013

    Re: Adodc Recordsource (HELP)

    > "So i made a program that creates a table using a name from textbox ..."

    Bad Idea.

    Database != WorkBook.
    Table != Spreadsheet.

    • If the user enters a name that isn't a valid table name for your database, your application dies.
    • If the user enters something "nasty", your application dies.
      Obligatory XKCD Reference: Little Bobby Tables
    • Having created a table, you then need some way of knowing what that table was called. That's generally done by having another table that holds all the table names! It rapidly gets very complicated, making more work for you.

    Unless you have a very, very good reason to do so, you should be using a single table for this and the values entered are just fields within that table, for example:

    select * from users ; 
    | id | Last_Name  | First_Name | Middle_Name | 
    |  1 | Flintstone | Frederick  | Joseph      | 
    |  2 | Flintstone | Wilma      |             | 
    Regards, Phill W.

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