New record then update Combobox w/next

brpallet

New member
Local time
Today, 02:29
Joined
Feb 28, 2009
Messages
7
I need help writing a line of code that creates a new record and populates a combo box with the next item on the list.

I have a form for employee time that has a combo box with employee names and a subform for the time punches linked to the employee. The combo box is bound to the employee id numbers.

I used the following code but Access does not make things as simple as I think it should be.:confused:

EmpID = Me.Employee.ListIndex 'Current Employee
DoCmd.GoToRecord , , acNewRec 'Create New Record
Me.Employee.ListIndex = EmpID + 1 'Next Employee

The first line works and so does the second. I used a msgbox to display the EmpID and it was right every time. But the listindex seems to be read only.

What is the easy way to perform this action.
 
A picture or a file would help here so someone could get a handle on it.
 
I will post something this afternoon.
 
Here is the database with only a few records. The problem is on the payroll form. Also if you could help with the formula on the punch detail page that calculates the hours I would appreciate it.

The code should be written to roll through the employees and once a record for the last employee is created, a msgbox would be displayed showing the fact and then start at the beginning.
 

Attachments

I need help writing a line of code that creates a new record and populates a combo box with the next item on the list.
Pallet,

your database needs a tiny bit of work, IMO...i just kinda used what i could to fix the "next" and "prev" buttons for you. the setup is odd, but still doable. i used SENDKEYS(), which noone really likes, including me. :) maybe this will head you in the right direction.

Also, if at all possible, please drop the DLOOKUPS() in the on change event of the combo. if the database becomes of any size, this will be a huge waste of space / memory, and runtime resources. dlookups should be completely avoidable in a datbase if possible. IMO.
 

Attachments

Thank you ajetrumpet for taking the time to help. I tried your file and could not get the send keys to work. When I tried the buttons it would flash the screen and advance to a new record but did not hold the combo box value. I think because it is tied to a table. Also the prev employee button did not go to the past record.

Any suggestions?? And I am using Access 2007 but creating it for a 2003 machine.

How would I go about eliminating the Dlookups? I was going to use a query but if the employee gets a raise than reports and forms would be hardered to create. I think.

I am still learning... and this is my first database. I normally stick to Excel
 
good luck with it. If you need professional assistance, i'm sure it's around. :) it's still in the baby stage. =)
 

Users who are viewing this thread

Back
Top Bottom