coolcatkelso
Registered User.
- Local time
- Today, 18:37
- Joined
- Jan 5, 2009
- Messages
- 279
Hiya
Trying to find the next Autonumber for WorkorderID
Getting stuck on the SELECT Statement
Function ShowIdentity() As Variant
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = DBEngine(0)(0)
db.Execute "INSERT INTO Workorders (CustomerID, EmployeeID, DateofAcceptance, StartDate, RepairNotes, EndDate, SalesTaxRate, Comments, QuoteID )"
SELECT Quotes.CustomerID, Quotes.EmployeeID, Quotes.DateofQuote, Quotes.RequestedStartDate, Quotes.WorkRequested, Quotes.ExpectedEndDate, Quotes.SalesTaxRate, Quotes.Comments, Quotes.QuoteID
FROM Quotes;
Set rs = db.OpenRecordset("SELECT @@IDENTITY AS LastID;")
ShowIdentity = rs!LastID
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
Doesn't matter what I do, the SELECT statement is showing RED all the time and coming up with Styntax Error
What am I doing wrong?
Am I correct in thinking, that if I have the INSERT INTO statement in here, I shouldn't needthe append query?
Cheers
CCK
________
BODY SCIENCE
Trying to find the next Autonumber for WorkorderID
Getting stuck on the SELECT Statement
Function ShowIdentity() As Variant
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = DBEngine(0)(0)
db.Execute "INSERT INTO Workorders (CustomerID, EmployeeID, DateofAcceptance, StartDate, RepairNotes, EndDate, SalesTaxRate, Comments, QuoteID )"
SELECT Quotes.CustomerID, Quotes.EmployeeID, Quotes.DateofQuote, Quotes.RequestedStartDate, Quotes.WorkRequested, Quotes.ExpectedEndDate, Quotes.SalesTaxRate, Quotes.Comments, Quotes.QuoteID
FROM Quotes;
Set rs = db.OpenRecordset("SELECT @@IDENTITY AS LastID;")
ShowIdentity = rs!LastID
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
Doesn't matter what I do, the SELECT statement is showing RED all the time and coming up with Styntax Error
What am I doing wrong?
Am I correct in thinking, that if I have the INSERT INTO statement in here, I shouldn't needthe append query?
Cheers
CCK
________
BODY SCIENCE
Last edited: