alexandria
New member
- Local time
- Today, 08:27
- Joined
- May 7, 2011
- Messages
- 6
I can't figure out what's wrong with this coding. On my first form (New_SelectName), the user selects their name from a combo box and clicks OK. This name and a generic ProjectName are added to the "NewProjects" table, and a second form opens for the user to enter their information into. I have the following query set as the second form's Record Source:
SELECT NewProjects.ProjectName, NewProjects.Researcher, NewProjects.*
FROM Economists INNER JOIN NewProjects ON Economists.Researcher = NewProjects.Researcher
WHERE (((NewProjects.ProjectName)="Test") AND ((NewProjects.Researcher)=[Forms]![New_SelectName]![nsResearcher]));
The query and INSERT INTO statement (see below) both work on their own, but the Researcher name and ProjectName do not appear in their controls on the second form. I guess the filter isn't working properly. I used this SetFocus/Requery business on a different set of forms without a problem, so I can't understand why it is not working here.
Private Sub nsOK_btn_Click()
DoCmd.SetWarnings (False)
Dim strSQL As String
strSQL = "INSERT INTO NewProjects (Researcher, ProjectName) VALUES ('" & Forms!New_SelectName!nsResearcher & "', 'Test');"
DoCmd.RunSQL strSQL
DoCmd.SetWarnings (True)
DoCmd.OpenForm "New_EnterProject"
With Forms!New_EnterProject
.SetFocus
.Requery
End With
End Sub
SELECT NewProjects.ProjectName, NewProjects.Researcher, NewProjects.*
FROM Economists INNER JOIN NewProjects ON Economists.Researcher = NewProjects.Researcher
WHERE (((NewProjects.ProjectName)="Test") AND ((NewProjects.Researcher)=[Forms]![New_SelectName]![nsResearcher]));
The query and INSERT INTO statement (see below) both work on their own, but the Researcher name and ProjectName do not appear in their controls on the second form. I guess the filter isn't working properly. I used this SetFocus/Requery business on a different set of forms without a problem, so I can't understand why it is not working here.
Private Sub nsOK_btn_Click()
DoCmd.SetWarnings (False)
Dim strSQL As String
strSQL = "INSERT INTO NewProjects (Researcher, ProjectName) VALUES ('" & Forms!New_SelectName!nsResearcher & "', 'Test');"
DoCmd.RunSQL strSQL
DoCmd.SetWarnings (True)
DoCmd.OpenForm "New_EnterProject"
With Forms!New_EnterProject
.SetFocus
.Requery
End With
End Sub