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

Update Query--Special Purpose

Status
Not open for further replies.

MontgomeryPete

Instructor
Apr 3, 2004
57
0
0
US
Hello:

I am trying to develop a quick application where "tickets" could be generated quickly for a transportation service. Basically, I am trying to print these with MS Access label function so they can be obtained on demand.

The following sample code should take the text input in Ticket and add records, with an auto number field ([ID]) into Ticket1.

Code:
INSERT INTO Tickets1 ( ID, [Company Name], [Address Street], [Address City], Comment, Telephone, [Ticket Comment], [Ticket Value])
SELECT Tickets.ID, Tickets.[Company Name], Tickets.[Address Street], Tickets.[Address City], Tickets.Comment, Tickets.Telephone, Tickets.[Ticket Comment], Tickets.[Ticket Value], Tickets.[Ending Value]
FROM Tickets INNER JOIN Tickets1 ON Tickets.ID = Tickets1.ID
WHERE (((Tickets.ID)<200));

This should be fairly simple if I had learned VBA, but I'm still in the SQL world.

Your help is appreciated.

Thanks, Pete

 
I don't understand the purpose of joining to Tickets1 when that is the table you are appending records to.

Your join condition ON Tickets.ID = Tickets1.ID will return only those records where ID already exists in Tickets1.

Further, if ID is an Autonumber field then you can't set its value. Access assigns the value for an autonumber field.
 
Thanks. I got rid of the join and the auto number. I added a function I found on TechOnLine (Access section)to enable a loop to control the ticket number field. My work is not elegant, but it got the job done.

Thanks for taking a look at this for me.

Pete

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top