
Why doesn't this button work?
I can't get the following code to work. It is attached to the click event
on a button on a subform. The button is in the form footer. It goes
through to see which consultants have a check in the checkbox next to their
name. If so, it is suppose to take them out of the "bullpen" and staff them
on the project. So, it deletes them from the "bullpen" table and adds them
to the "staffed" table. I'm sorry the code doesn't follow naming
conventions, I picked it up from someone else. Anyway, when I click the
button NOTHING happens except the screen refreshes. Any help you can answer
me here, or better yet e-mail me because I'll get it faster.
Thank you.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''
Private Sub btnHeresTeam_Click()
Dim dbs As Database
Dim rec As Recordset
Dim Value1 As String
Dim Value2 As String
Dim Value3 As String
Dim Value4 As Date
Dim Value5 As Date
'ID number of project
Value1 = [Forms]![test -staffing]![PCode]
'ID number of consultant
Value2 = Forms![test -staffing]![bullpen subform].Form![IDNumb]
'Utilization needed for project
Value3 = Forms![test -staffing]![bullpen subform].Form![Utilization]
'Start date of project
Value4 = Forms![test -staffing]![bullpen subform].Form![Start]
'End date of project
Value5 = Forms![test -staffing]![bullpen subform].Form![End]
Set dbs = CurrentDb
Set rec = dbs.OpenRecordset("qryStaffedBullpen")
Do Until rec.EOF
'If the checkbox is checked then...
If Forms![test -staffing]![bullpen subform].Form![Team_C] = True Then
'Runs an append query that inserts the selected values from the
' bullpen subform to the staffed table
dbs.Execute "INSERT INTO staffed " _
& "(Project_ID, idnumb, Utilization, start,end) VALUES " _
& "('" & Value1 & "','" & Value2 & "','" & Value3 & "','" &
Value4 & "','" & Value5 & "');"
'Runs an update query that subtracts the utilization required for
the proj.
' from the staff members avail. utilization.
dbs.Execute "UPDATE people SET Utilization_f = utilization_f - '" &
Value3 & "' WHERE idnumb = '" & Value2 & "'"
End If
rec.MoveNext
Loop
dbs.close
Forms("Test -Staffing").Requery 'Refreshes the screen
End Sub