![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a couple of tables called tbl_EMPLYE (has EMPLYE_ID as autonumber PK) and tbl_TIMESHEET (has TIMESHEET_ID as autonumber PK, and EMPLYE_ID as FK) based on a one to many relationship. These use a form and subform where the form is based on tbl_EMPLYE and has a combo box based on employee. The subform is based on tbl_TIMESHEET and the two are linked by the EMPLYE_ID column. The frm_EMPLYE displays the Employee number and the Start Date they started a placement (always a Monday date). The frm_TIMESHEET displays a Week ending date (always a Sunday) along with a few other fields in a tabulated layout. What I need is a command button on the EMPLYE form that will create 26 records (timesheets) in the tbl_TIMESHEET table where each week ending date displays accordingly. For example. If the Start Date on the main form (frm_EMPLYE) is 19- JUL-2010 (a Monday date), I want 26 records in the subform to show (showing Sunday dates): 25-JUL-2010 01-AUG-2010 08-AUG-2010 etc.. What I then need is for the command button to be disabled on the frm_EMPLYE form for each employee that has had the 26 records added (would this be used in conjunction with a flag or something????) Any help would be greatly appreciated (or alternative solution) Cheers. |
#3
| |||
| |||
|
|
I have a couple of tables called tbl_EMPLYE (has EMPLYE_ID as autonumber PK) and tbl_TIMESHEET (has TIMESHEET_ID as autonumber PK, and EMPLYE_ID as FK) based on a one to many relationship. These use a form and subform where the form is based on tbl_EMPLYE and has a combo box based on employee. The subform is based on tbl_TIMESHEET and the two are linked by the EMPLYE_ID column. The frm_EMPLYE displays the Employee number and the Start Date they started a placement (always a Monday date). The frm_TIMESHEET displays a Week ending date (always a Sunday) along with a few other fields in a tabulated layout. What I need is a command button on the EMPLYE form that will create 26 records (timesheets) in the tbl_TIMESHEET table where each week ending date displays accordingly. For example. If the Start Date on the main form (frm_EMPLYE) is 19- JUL-2010 (a Monday date), I want 26 records in the subform to show (showing Sunday dates): 25-JUL-2010 01-AUG-2010 08-AUG-2010 etc.. What I then need is for the command button to be disabled on the frm_EMPLYE form for each employee that has had the 26 records added (would this be used in conjunction with a flag or something????) Any help would be greatly appreciated (or alternative solution) Cheers. |
#4
| |||
| |||
|
|
I have a couple of tables called tbl_EMPLYE (has EMPLYE_ID as autonumber PK) and tbl_TIMESHEET (has TIMESHEET_ID as autonumber PK, and EMPLYE_ID as FK) based on a one to many relationship. These use a form and subform where the form is based on tbl_EMPLYE and has a combo box based on employee. The subform is based on tbl_TIMESHEET and the two are linked by the EMPLYE_ID column. The frm_EMPLYE displays the Employee number and the Start Date they started a placement (always a Monday date). The frm_TIMESHEET displays a Week ending date (always a Sunday) along with a few other fields in a tabulated layout. What I need is a command button on the EMPLYE form that will create 26 records (timesheets) in the tbl_TIMESHEET table where each week ending date displays accordingly. For example. If the Start Date on the main form (frm_EMPLYE) is 19- JUL-2010 (a Monday date), I want 26 records in the subform to show (showing Sunday dates): 25-JUL-2010 01-AUG-2010 08-AUG-2010 etc.. What I then need is for the command button to be disabled on the frm_EMPLYE form for each employee that has had the 26 records added (would this be used in conjunction with a flag or something????) Any help would be greatly appreciated (or alternative solution) Cheers. |
#5
| |||
| |||
|
|
Carl wrote: I have a couple of tables called tbl_EMPLYE (has EMPLYE_ID as autonumber PK) *and tbl_TIMESHEET (has TIMESHEET_ID as autonumber PK, and EMPLYE_ID as FK) based on a one to many relationship. *These use a form and subform where the form is based on tbl_EMPLYE and has a combo box based on employee. *The subform is based on tbl_TIMESHEET and the two are linked by the EMPLYE_ID column. The frm_EMPLYE displays the Employee number and the Start Date they started a placement (always a Monday date). The frm_TIMESHEET displays a Week ending date (always a Sunday) along with a few other fields in a tabulated layout. What I need is a command button on the EMPLYE form that will create 26 records (timesheets) in the tbl_TIMESHEET table where each week ending date displays accordingly. For example. *If the Start Date on the main form (frm_EMPLYE) is 19- JUL-2010 (a Monday date), I want 26 records in the subform to show (showing Sunday dates): 25-JUL-2010 01-AUG-2010 08-AUG-2010 etc.. What I then need is for the command button to be disabled on the frm_EMPLYE form for each employee that has had the 26 records added (would this be used in conjunction with a flag or something????) Any help would be greatly appreciated (or alternative solution) Cheers. The commands for your command button would be something like: Private Sub Sheets_Click() Dim WeekCount As Byte Dim EndDate As Date EndDate = DateAdd("d", 6, Me.EMPLYE_StartDate) For WeekCount = 1 To 26 * * DoCmd.RunSQL "INSERT INTO TIMESHEET(EMPLYE_ID,WeekEndingDate) " &_ * * * * "VALUES(" & Me.EMPLYE_ID & ",#" & EndDate & "#)" * * EndDate = DateAdd("d", 6, EndDate) Next 'show the added sheets Me.TIMESHEET_Subform.Requery 'field that tells you sheets are generated Me.SHEETS_ADDED = True Me.SHEETS_ADDED.SetFocus 'Sheets is the name of the command button Me.Sheets.Visible = False End Sub In the event Current of the form you can check the value of 'Me.SHEETS_ADDED' and make the button (un)visible accordingly. -- Groeten, Peterhttp://access.xps350.com --- news://freenews.netfront.net/ - complaints: n... (AT) netfront (DOT) net ---- Hide quoted text - - Show quoted text - |
#6
| |||
| |||
|
|
Carl wrote: I have a couple of tables called tbl_EMPLYE (has EMPLYE_ID as autonumber PK) *and tbl_TIMESHEET (has TIMESHEET_ID as autonumber PK, and EMPLYE_ID as FK) based on a one to many relationship. *These use a form and subform where the form is based on tbl_EMPLYE and has a combo box based on employee. *The subform is based on tbl_TIMESHEET and the two are linked by the EMPLYE_ID column. The frm_EMPLYE displays the Employee number and the Start Date they started a placement (always a Monday date). The frm_TIMESHEET displays a Week ending date (always a Sunday) along with a few other fields in a tabulated layout. What I need is a command button on the EMPLYE form that will create 26 records (timesheets) in the tbl_TIMESHEET table where each week ending date displays accordingly. For example. *If the Start Date on the main form (frm_EMPLYE) is 19- JUL-2010 (a Monday date), I want 26 records in the subform to show (showing Sunday dates): 25-JUL-2010 01-AUG-2010 08-AUG-2010 etc.. What I then need is for the command button to be disabled on the frm_EMPLYE form for each employee that has had the 26 records added (would this be used in conjunction with a flag or something????) Any help would be greatly appreciated (or alternative solution) Cheers. The commands for your command button would be something like: Private Sub Sheets_Click() Dim WeekCount As Byte Dim EndDate As Date EndDate = DateAdd("d", 6, Me.EMPLYE_StartDate) For WeekCount = 1 To 26 * * DoCmd.RunSQL "INSERT INTO TIMESHEET(EMPLYE_ID,WeekEndingDate) " &_ * * * * "VALUES(" & Me.EMPLYE_ID & ",#" & EndDate & "#)" * * EndDate = DateAdd("d", 6, EndDate) Next 'show the added sheets Me.TIMESHEET_Subform.Requery 'field that tells you sheets are generated Me.SHEETS_ADDED = True Me.SHEETS_ADDED.SetFocus 'Sheets is the name of the command button Me.Sheets.Visible = False End Sub In the event Current of the form you can check the value of 'Me.SHEETS_ADDED' and make the button (un)visible accordingly. -- Groeten, Peterhttp://access.xps350.com --- news://freenews.netfront.net/ - complaints: n... (AT) netfront (DOT) net ---- Hide quoted text - - Show quoted text - |
![]() |
| Thread Tools | |
| Display Modes | |
| |