OpenForm asks for parameter value (1 Viewer)

alexandria

New member
Local time
Today, 02:39
Joined
May 7, 2011
Messages
6
I'm using the WhereCondition of OpenForm to filter to the correct form. I need to use the values in 2 form controls plus the value of a DCount I perform shortly before the OpenForm. My code sort of works-instead of picking up the DCount's value, I get a popup asking for the parameter value (once entered the correct form opens). Can anyone see a problem in my coding?

Private Sub usOK_btn_Click()
DoCmd.SetWarnings (False)
Dim UpdateCount As Integer
UpdateCount = DCount("*", "qUpdate_RecordCount")
If UpdateCount >= 1 Then
DoCmd.RunSQL "UPDATE ProjectUpdates SET UpdateNumber = " & UpdateCount & " WHERE '" & Forms!Update_SelectName!usResearcher & "' AND '" & Forms!Update_SelectName!usProjectName & "' AND [ProjectUpdates.UpdateNumber] = 0;"
End If
DoCmd.SetWarnings (True)

DoCmd.OpenForm "Update_EnterProject", , , "[ProjectUpdates.Researcher]= '" & Forms!Update_SelectName!usResearcher & "' AND [ProjectUpdates.ProjectName]= '" & Forms!Update_SelectName!usProjectName & "' AND [ProjectUpdates.UpdateNumber] = UpdateCount"
DoCmd.Close acForm, "Update_SelectName"
End Sub
 

boblarson

Smeghead
Local time
Yesterday, 23:39
Joined
Jan 12, 2001
Messages
32,059
Yep, I sure do spot the problem (the part in blue):
Code:
DoCmd.OpenForm "Update_EnterProject", , , [COLOR=red]"[ProjectUpdates.Researcher]= '" & Forms!Update_SelectName!usResearcher & "' AND [ProjectUpdates.ProjectName]= '" & Forms!Update_SelectName!usProjectName & "' AND [ProjectUpdates.UpdateNumber] = [B][COLOR=blue]UpdateCount"[/COLOR][/B][/COLOR]

It should be:
Code:
DoCmd.OpenForm "Update_EnterProject", , , [COLOR=red]"[ProjectUpdates.Researcher]= '" & Forms!Update_SelectName!usResearcher & "' AND [ProjectUpdates.ProjectName]= '" & Forms!Update_SelectName!usProjectName & "' AND [ProjectUpdates.UpdateNumber] = [COLOR=blue][B]" & UpdateCount[/B][/COLOR][/COLOR]
 

alexandria

New member
Local time
Today, 02:39
Joined
May 7, 2011
Messages
6
That worked! Thanks, Bob.
 

Users who are viewing this thread

Top Bottom