473,413 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Syntax error FROM clause problem

72
hi there can anyone tell me wats wrong with my program, its a like this i have a database called "dbTimescheduling", 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:



Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim rs As New ADODB.Recordset
  3. Dim db As New ADODB.Connection
  4. Dim cnn As New ADODB.Connection
  5.  
  6. Set db = New ADODB.Connection
  7. cnn.ConnectionString = _
  8.  "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  9.           "Data Source=" & App.Path & "\dbTimeScheduling.mdb;"
  10. cnn.Open
  11.  
  12. Set rs = New ADODB.Recordset
  13. rs.Open "Select * from Time;", cnn, adOpenKeyset, adLockOptimistic
  14.  
  15. 'Courses
  16. cboCourse.AddItem "B.S. AERONAUTICAL ENGINEERING"
  17. cboCourse.AddItem "B.S. AIR TRANSPORTATION"
  18. cboCourse.AddItem "B.S. AIR MAINTENANCE TECHNOLOGY"
  19. cboCourse.AddItem "B.S. AVIONICS TECHNOOGY"
  20. cboCourse.AddItem "B.S. TOURISM"
  21. cboCourse.AddItem "B.S. AIRLINE BUSINESS ADMINISTRATION"
  22. cboCourse.AddItem "B.S. AIRLINE OFFICE ADMINISTRATION"
  23. cboCourse.AddItem "B.S. HOTEL & RESTAURANT MANAGEMENT"
  24. cboCourse.AddItem "AIRCRAFT TECHNICIAN"
  25.  
  26. 'Semester
  27. cboSemester.AddItem "1st Semester"
  28. cboSemester.AddItem "2nd Semester"
  29. cboSemester.AddItem "Summer"
  30.  
  31. 'Time
  32.     If rs.State = adStateOpen Then rs.Close
  33.        rs.Open "Select Time from Time", db, adOpenDynamic, adLockOptimistic
  34.  
  35.    For x = 1 To 15
  36.  
  37.         While rs.EOF <> True
  38.          Combo1(x).AddItem rs.Fields(Time).Value
  39.          rs.MoveNext
  40.  
  41.         Wend
  42.  
  43.    Next x
  44.  
  45.    If Combo1(x).ListCount > 0 Then Combo1(x).ListIndex = 0
  46.  
  47.  
  48.  
  49. End Sub
  50.  
The error is in this area of my code:
Expand|Select|Wrap|Line Numbers
  1. Set rs = New ADODB.Recordset
  2. rs.Open "Select * from Time;", cnn, adOpenKeyset, adLockOptimistic
  3.  
i hope someone can figure wats wrong with my code. am getting a error of
"Syntax error FROM clause"... thank you in advance
May 11 '07 #1
1 1325
danp129
323 Expert 256MB
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.
May 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
3
by: Jerry | last post by:
Well, here is some weirdness. First, I noticed that I have 2 Set keywords (silly me). so I removed the 2nd "Set" but still got a syntax error. Then I removed the Where clause, and now it works...
3
by: bilbo | last post by:
Can anybody help me understand why I get the error "Syntax error in CONSTRAINT clause"? I get it in Access 2003 and Access 2007. Both are clean installs with no add-ins Running this code in...
7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.