Hello,
I’ve been working on a project and I need a little help. I have 3 tables; tblProjects, tblTesting, and tblEmployees. The issue I’m having is that I’ve created a form which collects testing information from testers that test a particular project. Each project can have multiple testers. tblProject and tblTesters have a one to many relationship and the form (frmTesting) consists of a main form for project info and a subfrom for testing info. For each project tested there are 4 possible outcomes. 1st not all testers have tested to project and that case project status is “InTesting”, 2nd all testers pass testing in that case project staus is “Waiting Final Approval”, 3rd all testers fail testing in that case project status is “Maintenance” and last some testers pass and some fail in that case project status is “IPR”. Here is my code for a button I’ve placed on the sub form.
Private Sub BtnTest_Click()
Dim db As DAO.Database
Dim rsSQL As DAO.Recordset
Dim intMax As Integer
Dim strSQL As String
Dim csSQL As String
Set db = CurrentDb()
strSQL = "SELECT * FROM Testing WHERE Testing.ProjNum ='" & ProjNbr_Txtbox & "'"
Set rsSQL = db.OpenRecordset(strSQL, dbOpenSnapshot)
intMax = rsSQL.RecordCount
rsSQL.MoveFirst
For intX = 1 To intMax
If Testing.TestCompleted_Date Is Null Then
Exit Sub ‘Not all testers have tested project status is already In Testing
End If
rsSQL.MoveNext
Next
rsSQL.MoveFirst
Do While Not rsSQL.EOF
For intY = 1 To intMax
If Me.Pass = False Then
Wend
End If
rsSQL.MoveNext
Next
DoCmd.SetWarnings False
csSQL = "UPDATE tblProjects SET [Status] = Waiting Final Approval ' WHERE [ProjectNumber] =" & ProjNbr_Txtbox & ""
DoCmd.SetWarnings True
Loop
rsSQL.MoveFirst
For intZ = 1 To intMax
If Me.Pass = True Then
DoCmd.SetWarnings False
csSQL = "UPDATE tblProjects SET [Status] = 'IPR' WHERE [ProjectNumber] =" & ProjNbr_Txtbox & ""
DoCmd.SetWarnings True
Exit For
End If
rsSQL.MoveNext
DoCmd.SetWarnings False
csSQL = “UPDATE tblProjects SET [Status] = 'Maintenance' WHERE [ProjectNumber] =" & ProjNbr_Txtbox & ""
DoCmd.SetWarnings True
Next
End Sub
My select statement for my recordset isn't working and I've tested it by putting a specific project number in the statement and I still only pulling one recordset. Any help would be greatly appreciated. Plus I’m not sure my loops are the most effient, could use some help with those too. Thanks Randy
I’ve been working on a project and I need a little help. I have 3 tables; tblProjects, tblTesting, and tblEmployees. The issue I’m having is that I’ve created a form which collects testing information from testers that test a particular project. Each project can have multiple testers. tblProject and tblTesters have a one to many relationship and the form (frmTesting) consists of a main form for project info and a subfrom for testing info. For each project tested there are 4 possible outcomes. 1st not all testers have tested to project and that case project status is “InTesting”, 2nd all testers pass testing in that case project staus is “Waiting Final Approval”, 3rd all testers fail testing in that case project status is “Maintenance” and last some testers pass and some fail in that case project status is “IPR”. Here is my code for a button I’ve placed on the sub form.
Private Sub BtnTest_Click()
Dim db As DAO.Database
Dim rsSQL As DAO.Recordset
Dim intMax As Integer
Dim strSQL As String
Dim csSQL As String
Set db = CurrentDb()
strSQL = "SELECT * FROM Testing WHERE Testing.ProjNum ='" & ProjNbr_Txtbox & "'"
Set rsSQL = db.OpenRecordset(strSQL, dbOpenSnapshot)
intMax = rsSQL.RecordCount
rsSQL.MoveFirst
For intX = 1 To intMax
If Testing.TestCompleted_Date Is Null Then
Exit Sub ‘Not all testers have tested project status is already In Testing
End If
rsSQL.MoveNext
Next
rsSQL.MoveFirst
Do While Not rsSQL.EOF
For intY = 1 To intMax
If Me.Pass = False Then
Wend
End If
rsSQL.MoveNext
Next
DoCmd.SetWarnings False
csSQL = "UPDATE tblProjects SET [Status] = Waiting Final Approval ' WHERE [ProjectNumber] =" & ProjNbr_Txtbox & ""
DoCmd.SetWarnings True
Loop
rsSQL.MoveFirst
For intZ = 1 To intMax
If Me.Pass = True Then
DoCmd.SetWarnings False
csSQL = "UPDATE tblProjects SET [Status] = 'IPR' WHERE [ProjectNumber] =" & ProjNbr_Txtbox & ""
DoCmd.SetWarnings True
Exit For
End If
rsSQL.MoveNext
DoCmd.SetWarnings False
csSQL = “UPDATE tblProjects SET [Status] = 'Maintenance' WHERE [ProjectNumber] =" & ProjNbr_Txtbox & ""
DoCmd.SetWarnings True
Next
End Sub
My select statement for my recordset isn't working and I've tested it by putting a specific project number in the statement and I still only pulling one recordset. Any help would be greatly appreciated. Plus I’m not sure my loops are the most effient, could use some help with those too. Thanks Randy