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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 3075 Invalid Syntax in From Statement ? 1

Status
Not open for further replies.

jkejke

Programmer
Jan 18, 2001
35
US
Trying to pull last value in Table--and then increment by one--Here is code
Private Sub DateRequest_AfterUpdate()

Dim EDPTRACK As Database
Dim RsTblProject As Recordset
Dim MySql As String
Dim strAA As String
Dim StrDate As String
Dim StrOut As String
Dim Rstsx As Variant


'UserControl Value is input by user
strAA = UserControl.Value
'Date request is input by user--then we take the year add
' "20" to it and get 2001, 2000, 2002, etc
StrDate = Right(DateRequest, 2)
StrDate = "20" + StrDat
'strOut is Straa & StrDate with formatting to match field
'TxtYrVAlue in tblproject---
StrOut = strAA + StrDate
StrOut = strAA & "-" & StrDate
'Get all from tblProject where strout=Txtyrvalue may be 1
' or more in dynaset
'Getting error 3075 invalid syntax in FROM Statement
MySql = " SELECT * FROM TblProject" _
& " WHERE (((TblProject.TxtYrValue))='" + StrOut & "';)"

'setting EDPTRACK as Current Database
Set EDPTRACK = CurrentDb
'setting rstblproject as dynaset that meets MYsql Statement
Set RsTblProject = EDPTRACK.OpenRecordset(MySql, _ dbOpenDynaset)

'in dynaset move to last record
RsTblProject.MoveLast
'move value from Last Val to Rstsx increment by one

Rstsx = LastVal + 1

'pad Rstsx to look like 00002
Rstsx = "000" + Rstsx
'take right 3 of string Rstsx
Rstsx = Right(Rstsx, 3)
'Creat ID for Record being input
RequestID.Value = strAA & "-" & StrDate & "-" & Rstsx

'move strout to record being input
TxtYrValue = StrOut
'move Rstsx to record being input to be able to find next record
LastVal = Rstsx


'Do not accept a date more than 30 days prior to current date
If DateRequest < Date - 30 Then
MsgBox (&quot;You must enter a date within the last 30 days!!&quot;)
'daterequest not locked if more than 30 days prior to
' current date
DateRequest.Locked = False
'setting focus back to UserControl that has been
'locked and can not be changed for them to go back to
'DateRequest
UserControl.SetFocus
Else
'if date good then lock DateRequest--allow no change
'at input level
DateRequest.Locked = False

End If

End Sub

Any help or ideas would be greatly appreciated--
 
I would try eliminating a few sets of those extraneous parentheses you have up there...

Not sure that would fix it, but it's worth a shot --

Then, maybe step through the code and look at what the value of the mySQL is once it's declared with that assignment statement -- I bet the error would be readily apparent if you did that -- looks like too simple of a statement to be too difficult to find the error in it.

good luck! :)
Paul Prewett
 
Hi jkejke,

There appears to be something wrong with this line:

MySql=&quot;SELECT TblProject.* FROM TblProject WHERE (((TblProject.TxtYrValue)) = '&quot; & StrOut & &quot;')&quot;

might work for you! :) Gord
ghubbell@total.net
 
Hi,

First, get rid of all those parentheses they are not needed. The semi-colon is on the wrong side of the last parenthesis.

Have a good one!
BK
 
Thanks for help--worked using combo of what was sent--
THIS PROJECT IS HISTORY

Seems kind of bad to finish up the project by doing the primary key last--

Again Thanks to all who responded
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top