•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Database Design section within the Web Development category of DaniWeb, a massive community of 422,675 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,700 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Database Design advertiser: Programming Forums
Views: 1101 | Replies: 2
![]() |
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.
•
•
Join Date: Jan 2008
Location: London, England
Posts: 57
Reputation:
Rep Power: 1
Solved Threads: 6
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
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
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?
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?
![]() |
•
•
•
•
•
•
•
•
DaniWeb Database Design Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- showing the form after insertind data (PHP)
- PHP Form, SQL connectivity issues, please help. (MySQL)
- Syntax error (missing operator) in query expression 'OrderNo='.HELP PLEASE (ASP)
- SQL Query inserts junk data as well (ASP)
- Error while trying the update query (ASP)
- dreamweaver, PHP and submit form query (PHP)
- Query hell (MySQL)
- Populating a fields on a form base on a selected item from a droplist. (PHP)
Other Threads in the Database Design Forum
- Previous Thread: Inheritance Implementation (This does not ensure integrity )
- Next Thread: Cpying Tables from one DB to another


Linear Mode