Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Databse, Error: Syntax error in FROM clause. 1

Status
Not open for further replies.

SurvivorTiger

Programmer
Jul 9, 2002
265
US
Hey everyone,
I have done so many access database programs before and now i just made a really simple and small database and when i run the vb data form wizard and make a form, then i get an error that says: "Syntax error in FROM clause." i have no idea what that means and i had never gotten that error message!
any ideas what's wrong?

AIM: survivertiger & Ye This Is Me
 
Private Sub Form_Resize()
On Error Resume Next
'This will resize the grid when the form is resized
grdDataGrid.Height = Me.ScaleHeight - datPrimaryRS.Height - 30 - picButtons.Height
End Sub

Private Sub Form_Unload(Cancel As Integer)
Screen.MousePointer = vbDefault
End Sub

Private Sub datPrimaryRS_Error(ByVal ErrorNumber As Long, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, fCancelDisplay As Boolean)
'This is where you would put error handling code
'If you want to ignore errors, comment out the next line
'If you want to trap them, add code here to handle them
MsgBox "Data error event hit err:" & Description
End Sub

Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'This is where you put validation code
'This event gets called when the following actions occur
Dim bCancel As Boolean

Select Case adReason
Case adRsnAddNew
Case adRsnClose
Case adRsnDelete
Case adRsnFirstChange
Case adRsnMove
Case adRsnRequery
Case adRsnResynch
Case adRsnUndoAddNew
Case adRsnUndoDelete
Case adRsnUndoUpdate
Case adRsnUpdate
End Select

If bCancel Then adStatus = adStatusCancel
End Sub

Private Sub cmdAdd_Click()
On Error GoTo AddErr
datPrimaryRS.Recordset.MoveLast
grdDataGrid.SetFocus
SendKeys "{down}"

Exit Sub
AddErr:
MsgBox Err.Description
End Sub

Private Sub cmdDelete_Click()
On Error GoTo DeleteErr
With datPrimaryRS.Recordset
.Delete
.MoveNext
If .EOF Then .MoveLast
End With
Exit Sub
DeleteErr:
MsgBox Err.Description
End Sub

Private Sub cmdRefresh_Click()
'This is only needed for multi user apps
On Error GoTo RefreshErr
datPrimaryRS.Refresh
Exit Sub
RefreshErr:
MsgBox Err.Description
End Sub

Private Sub cmdUpdate_Click()
On Error GoTo UpdateErr

datPrimaryRS.Recordset.UpdateBatch adAffectAll
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub


AIM: survivertiger & Ye This Is Me
 
i dont see any SQL here . . . lone84 is right . . . dont forget to paste your SQL . . . that error is really on your SQL

Please pardon the grammar.
Not good in english.
 
ummm...i'm not sure what you guys are talking about...because i didn't program anything in SQL, i used Microsoft Access...

AIM: survivertiger & Ye This Is Me
 
The FROM clause is from an SQL statement, and is probably the means by which the datPrimaryRS Recordset is being populated. What is being asked for is that SQL Statement, or perhaps you using a Query from inside the Access database.

Where in your code is the datPrimaryRS being opened and/or populated? Is it a data property of a bound control? Or are you opening the recordset somewhere in the code. That's the code in question.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
The cause is the Query or the rst.open statement that you use to connect to the database.

If you are using a table name to open the recordset, try putting [] around the table name. Like

rst.open "[tablename]"

The table name now u r using may be a keyword..
 
SurvivorTiger, check the RecordSource property of the DataControl (in the property window, or if you are doing it somewhere in code), and if necessary, post the value of it here.
As vbSun says, very well could be just that (a table or field name in the MDB is an ANSI '92 reserved word), esp. if you haven't typed in the Recordsource yourself.

 
wow...i'm really confused...but I changed the name of the data control to datPrimaryRS2 instead of datPrimaryRS and then it wouldn't give me the FROM clause error anymore, but when the form loaded up, it would just show two empty columns...this is the weirdest thing ever!

AIM: survivertiger & Ye This Is Me
 
Perhaps you could post the value of the RecordSource property of the Data control from your original setup.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Try changing that SQL statement to the following:
Code:
select [Date], [Time], [Tip], [Hourly] from [Money] Order by [Date]
Date, Time are reserved words, and I suspect, in agreement with the other above, that Money is also a reserved word.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top