Syntax error FROM clause problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darrel
    New Member
    • Nov 2006
    • 72

    #1

    Syntax error FROM clause problem

    hi there can anyone tell me wats wrong with my program, its a like this i have a database called "dbTimescheduli ng", with a field with a name of "Time",,, for now i want to do is to be able to access the "Time" field in my program it must be displayed in a combo box array.. can someone help me out on this.. heres my code:



    Code:
    Private Sub Form_Load()
    Dim rs As New ADODB.Recordset
    Dim db As New ADODB.Connection
    Dim cnn As New ADODB.Connection
    
    Set db = New ADODB.Connection
    cnn.ConnectionString = _
     "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & App.Path & "\dbTimeScheduling.mdb;"
    cnn.Open
    
    Set rs = New ADODB.Recordset
    rs.Open "Select * from Time;", cnn, adOpenKeyset, adLockOptimistic
    
    'Courses
    cboCourse.AddItem "B.S. AERONAUTICAL ENGINEERING"
    cboCourse.AddItem "B.S. AIR TRANSPORTATION"
    cboCourse.AddItem "B.S. AIR MAINTENANCE TECHNOLOGY"
    cboCourse.AddItem "B.S. AVIONICS TECHNOOGY"
    cboCourse.AddItem "B.S. TOURISM"
    cboCourse.AddItem "B.S. AIRLINE BUSINESS ADMINISTRATION"
    cboCourse.AddItem "B.S. AIRLINE OFFICE ADMINISTRATION"
    cboCourse.AddItem "B.S. HOTEL & RESTAURANT MANAGEMENT"
    cboCourse.AddItem "AIRCRAFT TECHNICIAN"
    
    'Semester
    cboSemester.AddItem "1st Semester"
    cboSemester.AddItem "2nd Semester"
    cboSemester.AddItem "Summer"
    
    'Time
        If rs.State = adStateOpen Then rs.Close
           rs.Open "Select Time from Time", db, adOpenDynamic, adLockOptimistic
           
       For x = 1 To 15
        
            While rs.EOF <> True
             Combo1(x).AddItem rs.Fields(Time).Value
             rs.MoveNext
    
            Wend
    
       Next x
       
       If Combo1(x).ListCount > 0 Then Combo1(x).ListIndex = 0
       
    
    
    End Sub
    The error is in this area of my code:
    Code:
    Set rs = New ADODB.Recordset
    rs.Open "Select * from Time;", cnn, adOpenKeyset, adLockOptimistic
    i hope someone can figure wats wrong with my code. am getting a error of
    "Syntax error FROM clause"... thank you in advance
  • danp129
    Recognized Expert Contributor
    • Jul 2006
    • 323

    #2
    Don't use reserved words (IE Time) when naming a db/table/field and life will be easier.

    Not calling a field the same as a db or table will also make things easier...

    You may be able to refer to the field as [time] or [time].[time]

    I would suggest renaming the Time table to tblTime or tblSchedules and the Time field to sched_time or something.

    Comment

    Working...