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!

Runtime error 2342

Status
Not open for further replies.

jkejke

Programmer
Jan 18, 2001
35
US
get error Runtime error 2342--

A RunSql action requires an argument consisting of a SQL Statement

Below is the code--started on this last week--

Trying to creat Unique ID Field--General Discussion
tblyearvalue consists of two fields

UserGroup Value
UI-2001 1
AS-2001 1

Know it is something small most likely but have been looking at to much--can not see--anyone with any ideas

Created query--can do with no problem the sql for that is
SELECT [TXTYrValue] & "-" & ([Value]+1) AS Txtyearvalue, &_[TXTYrValue] & "-" & ([Value]+1) AS RequestID
FROM TblYearValue INNER JOIN TblProject ON TblYearValue.UserGroup = TblProject.TXTYrValue;

This works in the query--but not when transposed to the input form--


Code for input

Private Sub DateRequest_AfterUpdate()
Dim EDPTrack As Database
Dim rstTblYearValue As Recordset
Dim rsTblProject As Recordset
Dim MySql As String
Dim strAA As String
Dim StrDate As String
Dim strNumb As String
Dim StrOut As String
Dim strOuta As String
Dim strVal As String


strAA = UserControl.Value
StrDate = Right(DateRequest, 2)
StrDate = "20" + StrDate


'Setting up strout to go to tblYearValue to get value
StrOut = strAA + StrDate
StrOut = strAA & "-" & StrDate

MySql = "SELECT value FROM tblyearvalue WHERE &_ Usergroup='StrOut';"

DoCmd.RunSQL MySql

strNumb = MySql

strNumb = "000" + strNumb
strNumb = Right(strNumb, 3)
strOuta = Format(strAA + StrDate + strNumb, ">@@-@@@@-@@@")

RequestID.Value = strOuta

End Sub

WHEN THIS RUNS GETS THE LAST THREE CHARACTERS IN MYSQL
"T, ;"

 
Change your MySql assignment to:

MySql = "SELECT value FROM tblyearvalue WHERE " & _
"Usergroup='StrOut';"

You can't properly break the line in the middle of a string literal. You have to divide the literal and use "&" to join the pieces back together. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top