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

Adding new records to a subform (Datasheet)

Status
Not open for further replies.

glalsop

Technical User
Aug 9, 2003
435
US
Hi all-

I am using Access 2000. I have one table tblDailyTimeSheet that has 5 fields: pkeyTimeSheetID (AutoNumber), EmployeeID, TimeSheetDate, TimeIn, and TimeOut. This table stores daily time records for employees.

I have a second table, tblEmployeeActivities that tracks what employees do all day. Fields are pkeyActivityID (AutoNumber), fkeyTimeSheetID, ActivityCode, StartTime, FinishTime.

The tables are linked on the TimeSheetID fields.

I am building an input form based on a physical piece of paper that employees fill out every day. The main form is based on tblDailyTimeSheet and is to input time records. On the subform I want to enter all of the activities for the employee just entered on the main form (shown in datasheet view).

The problem comes when I open the form. I am having trouble determining which event procedure I need to use to populate the first record on the subform (assign the value of pkeyTimeSheetID on the main form to fkeyTimeSheetID), so that the user can begin entering all of that days activities for the current employee.

Hope that makes sense and I will be glad to provide more information if necessary.

Thanks,
Gary
 
Do you just need the TimeSheetID in the subform to be the same as the TimeSheetID in the main form?

Eric
 
Hi Eric -

Essentially, yes. I have the default value set up in the subform to reflect this, but am having trouble getting a new record to appear in the subform.

Thanks,
Gary
 
In the on open event of your subform add this line of code:


DoCmd.GoToRecord , , acNewRec


HTH,
Eric
 
Hi Eric,

Thanks again for your help. I tried your suggestion in the Load event and in the Open event of my subform and both times I got Run-time error '2105': You can't go to specified record.

On a positive note, I opened a previously saved version of the same database and switched the subform view in that copy to datasheet view, and everything works as expected. Problem solved!

I must have unknowingly set a property wrong in the one I was working on and couldn't find it.

Thanks agian though for your time.

-Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top