Results 1 to 2 of 2

Thread: Syntax error in "From" clause while using ADODC

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    22

    Syntax error in "From" clause while using ADODC

    Hi,

    I want to use "Adodc control in my Form.

    I have to necessarily use a variable name as "Table Name"


    I've used "From clause" within : With Adodc1...End With block

    ie. .RecordSource = " Select * From" & tableid

    I encouter : "Syntax error in From clause" when I run the application.

    Will you debug the syntax error please ?


    Actaul code
    ============


    Private Sub Form_Load()

    Dim tableid As Integer
    tableid = 10


    dbfile = App.Path & "\myfile.mdb"
    Set CN = New ADODB.Connection
    CN.ConnectionString = _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source='" & dbfile & "';" & _
    "Persist Security Info=False"
    CN.Open

    -----------------------------------------------------
    With Adodc1

    .ConnectionString = _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source='" & dbfile & "';" & _
    "Persist Security Info=False"

    .RecordSource = " Select * From" & tableid <----

    End With
    -----------------------------------------------------

    Set Text1.DataSource = Adodc1
    Set Text2.DataSource = Adodc1
    Text1.DataField = "Student_id"
    Text2.DataField = "Student_name"

    End sub

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    check your other thread, the answer is there.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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