need to check records in subform and delete man name from combo bo

B

babs

I set up the code below and it Overall works-
used below link to help me

I really need to add a new command button to the Main form to overall check
all of the people scheduled in the subform and delelte them from the dropdown
list cboman(combo box on main from based on table LISTTEMP)- all if delete
someone from the schedule in the subform want them ADDED back onto the combo
box so can schedule them again that given week end date.

See below code:

as of right now when I click on the present command button it schedules the
given person for that week and deletes them off of the dropdown. but would
like to add them other ways and want ONE button to REFRESH the combo box
cboman- based on what the Currrent records are in the subform ( based on a
query JeffTime Card MD Query)- see below code - crazily really need ASAP!!!

http://support.microsoft.com/default.aspx/kb/132026

here is the present code below:
Private Sub Command5_Click()
'START
Dim dteWeekday As Date
Dim i As Integer
Dim strSQL As String

DoCmd.SetWarnings False
' run your code
For i = 1 To 6 '(Monday to Saturday)
dteWeekday = DateAdd("d", -i, Me.txtDate) 'increment sunday by i days
strSQL = "INSERT INTO [JeffTime Card MD Query] ([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
'dteWeekday = DateAdd("d", -i, Me.txtDate)
Me.JeffTimeCardMDJEFFSubform.Requery

On Local Error GoTo Command5_AfterUpdate_Err

'NOTE: In Microsoft Access version 2.0, omit the Private keyword for the
'Sub statement and the Local keyword for the On Error sentence. In
'version 2.0, those keywords are not valid for these statements.

Dim db As Database, rs As Recordset, criteria As String
Dim UserMessage As String
Set db = CurrentDb()
' Create recordset based on the list box RowSource.
Set rs = db.OpenRecordset(Me!cboman.RowSource, _
DB_OPEN_DYNASET)
' Check for the existence of Null values.
If IsNull(Me!cboman) Then
MsgBox "Shrinking List is Null!"
Exit Sub
End If
UserMessage = Me!cboman
criteria = "[Man Name] = '" & Me!cboman & "'"
' Locate the record that was selected in the list box
' list and delete it.
rs.FindFirst criteria
rs.Delete
' Refresh the List Box's RowSource property entries.
Me!cboman.Requery
' Set the contents of the List Box to blank.
Me!cboman = Null
' Prompt user.
MsgBox "The Item " & UserMessage & " has been deleted!"
Exit Sub

Command5_AfterUpdate_Err:
MsgBox Error$
Exit Sub
DoCmd.SetWarnings True
End Sub


thanks soo much for helping,
BArb
 

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