when add new records grabs persons name from Previous record

B

babs

I have a command button on the Main form that I click to Insert records onto
the subform to schedule the jobs for that week. See Code below:

Private Sub InsertWKSched_Click()
'START
Dim dteWeedday As Date
Dim i As Integer
Dim strSQL As String

For i = 1 To 6 '(Monday to Saturday)
dteWeekday = DateAdd("d", Me.txtdate, -i) 'increment sunday by i days
strSQL = "INSERT INTO [TimeCardMDJEFF] ([workdate],[date],[man
name],[actualRate]) VALUES (#" & Format(dteWeekday, "m-d-yyyy") & "#," & "#"
& Format(Me.Date, "m-d-yyyy") & "#,""" & Me.cboman.Column(0) & """,""" &
Me.cboman.Column(1) & """)"
DoCmd.RunSQL (strSQL)
Next i
'END
Me.datbarbTimeCardMDJEFFSubform2.Requery

End Sub

It works but when i go to add a New record on the main form
and select a NEW a name to schedule - the new name shows up in the combo box
-
BUT when I go to insert the records(clicking on command button from code
above)It inserts the 6 records but - it grabs the name from the previous
record
that I put in - not sure what code I need to add and on what Place - on combo
box, on form or on command button to insert records to make it the Most
present name selected in combo box from the main form???
Need help bad - can't figure this out????

thanks soo much,
barb
 
D

Daryl S

If you save your main form before adding the subform records, then that will
put the new name in the database. Otherwise, in your Insert statement, refer
to the new name by the form control, not the database field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top