943,539 Members | Top Members by Rank

Ad:
Jan 30th, 2008
0

Get first number from query into new form

Expand Post »
I am using Access97 and have created an employee database. I am having trouble creating a method in which to get a new number for an employee and open a form in add mode with the new number already populated and then remove that number from the list of available numbers. This is how I currently do it. 1) Open switchboard and select Get New Employee ID. 2) Select from which group of employees I need a number (e.g Finance =1000-1999 HR= 2000 to 2999, IRM= 3000-3999, etc.) This brings up a list (Report based on a query) of available numbers for that range. I then write down the first number, close the report, go to the Available numbers table and delete the number manually, Then open up the Employee form and put in the number manually. I would rather have an option of when I click on the correct group of employees that a function would grab the first number from the selected query and then open the Employees form with the employee number populated and remove that number from the available nuumbers table. I have no problem going the other way. When I check the removal box and then select the purge button the employee gets removed from the active employees, their data transferred to the removed employees table and then their number appended to the available numbers table. I just don't know enough yet to figure out how to grab the first item in a query and use that item in the form I want to use and then delete that number from the other table. Sorry for writing a book. Thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
computerscott2 is offline Offline
5 posts
since Jan 2006
Jan 31st, 2008
0

Re: Get first number from query into new form

I dont know too much about access, but Im sure you can input sql commands somewhere, heres the sql i would use

SELECT employee_ID
FROM available_numbers
LIMIT 0, 1

the LIMIT 0, 1 just picks out the first entry for you
If you dont understand sql then i can look at access and find out how to implement if if you would like
Reputation Points: 11
Solved Threads: 6
Junior Poster in Training
hooray is offline Offline
62 posts
since Jan 2008
Jul 9th, 2008
0

Re: Get first number from query into new form

Thanks for your help. Because of your help I was pointed in a new direction and I figured out how to insert the SQL code into access97. Here’s how to do it. You open your query and then to the right of the view box (the one that toggles between build and view) is a down arrow where you can select SQL View. I had to play with the code as access97 did not like the Limit 0,1 statement. EIN is the Employee Id Number. Here is the final code that I used:

INSERT INTO Temp ( EIN ) 'This is a temporary table used to test if the query worked
SELECT TOP 1
AvailableEIN
FROM AvailableEIN
GROUP BY AvailableEIN
HAVING (((Min(AvailableEIN.AvailableEIN)) Between 1000 And 1999));

It returns the desired value! Hooray!

Now the next part of the question. How do I open up my Employee form in add mode and insert the selected value from above into it?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
computerscott2 is offline Offline
5 posts
since Jan 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Database Design Forum Timeline: Inheritance Implementation (This does not ensure integrity )
Next Thread in Database Design Forum Timeline: Cpying Tables from one DB to another





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC