-----Original Message-----
Thanks for your response.
Your code is a little bit advanced for me - I've tried
something similar but opening a form bound to the
underlying table instead - it works just the same, but
the code is more longwinded. Your opinion would be
welcome. I dont understand recordsets yet.
Private Sub Command115_Click()
Dim counterc As Integer
Dim counterl As Integer
DoCmd.OpenForm "tblKPIfrm", acViewNormal, acAdd
For counterc = 1 To 12
For counterl = 1 To 6
If Forms("frmSHIFTMASTER")("frmKPI")("Loss" & counterc &
counterl) > 0 Then
DoCmd.GoToRecord acDataForm, "tblKPIfrm", acNewRec
Forms![tblKPIfrm]![SHIFT] = Forms![frmSHIFTMASTER]! [SHIFT]
Forms![tblKPIfrm]![DATE] = Forms![frmSHIFTMASTER]! [DATE]
Forms![tblKPIfrm]![Line] = counterl
Forms![tblKPIfrm]![Category] = counterc
Forms![tblKPIfrm]![Loss] = Forms("frmSHIFTMASTER")
("frmKPI")("Loss" & counterc & counterl)
Else
End If
Next
Next
DoCmd.Close acForm, "tblKPIfrm", acSaveYes
End Sub
BTW, my date control is called DATE, it seems to work
alright. Should I change it?
Paul Foster
Bournemouth UK
-----Original Message-----
One approach would be to set up an unbound form just
like
your paper form.
I would create unbound controls for the shift and date
(don't use the reserved word 'date' for the field in the
table).
Add the labels for the line across the form and the
categories down the side. Create 72 unbound controls for
the time lost.
Create a button ('ADD'or 'ENTER DATA') to run code to
add
the records.
(See this site: Cycle through controls with common names
at
http://www.mvps.org/access/forms/frm0003.htm)
Think of the controls as an array; if the line table has
the entries (primary key) from 1 to 6 and the categories
(primary key) are 1 to 12, the controls for the time
lost
could be named Loss11, Loss12, Loss13, ... Loss612.
The cmdButton code would open an record set, loop thru
the
controls creating 72 records and close the recordset.
The loop would be two loops - an outer loop (x= 1 to 6)
for lines and an inner loop (y = 1 to 12) for
categories.
The code to create the records would :
Check to make sure the date control is valid
Check to make sure the shift is not null
Open the recordset
For x = 1 to 6 'the line
For y = 1 to 12 'the category
If Not IsNull(Me("Loss" & x & y).Value) ' optional
With rst 'recordset
.AddNew
.dteDate = Me.ShiftDate
.shift = Me.Shift
.Line = x ' the outer loop index
.Category = y ' the inner loop
.Loss = Me("Loss" & x & y).Value 'the time lost
.update
End With
End If 'optional
Close the recordset
Set rst = nothing
Do the loops again setting the controls to null to clear
them.
You can flesh out the rest of the code.....
(Don't forget a 'close form' button)
HTH
Steve
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)
-----Original Message-----
I'm trying to track time losses on different lines, and
have a table with fields for: record_id (autonumber);
date; shift; line - lookup to lines table (6); category
of loss - look up to categories table (12); and time
lost.
I'd like to have a form for each shift for supervisors
to
fill in, but am having a hard time putting it
together.
I want it to have the 6 lines across the top, with the
12
different categories down the side, giving 72 boxes to
be
filled in with time lost.
If I've got the information, I could easily display it
using a crosstab query, but whats the best way to
design
a form for inputting the data? I obviously want only
one
record per line/category per shift.
Any help would be greatly appreciated.
Thanks in advance
Paul Foster
Bournemouth UK
.
.
.