M
mcarlyle via AccessMonster.com
I have this code...
Private Sub Command21_Click()
Dim db As DAO.Database
Dim RS As DAO.Recordset
Dim leadinfo As String
If [Howmany] = 0 Then Exit Sub
If CInt([Howmany]) > [availleads] Then Exit Sub
If [Sales Rep Name] = Null Then Exit Sub
Set db = CurrentDb()
Set RS = db.OpenRecordset("qryUnassignedOldLeads", dbOpenDynaset)
SumLeads = DSum("CountOfSource", "qryUnassignedOldLeads")
Do Until RS.EOF
Percent = RS.Fields("CountOfSource") / SumLeads
NumLeads = CInt(Percent * [Howmany])
If NumLeads = 0 Then
NumLeads = 1
End If
'RS.Fields("CountOfSource"))
CurrentSource = RS.Fields("Source")
DoCmd.SetWarnings False
leadinfo = [Text15] & " " & NumLeads & " " & CurrentSource
MsgBox leadinfo, vbOKOnly, "info to pass"
DoCmd.RunSQL "UPDATE clients SET salesperson = " & Text15 & " WHERE ID IN
( SELECT TOP " & NumLeads & " ID FROM clients WHERE Salesperson IS NULL And
[task note] = 'Unworked Lead' And Source = """ & CurrentSource & """) "
DoCmd.SetWarnings True
RS.MoveNext
Loop
End Sub
It is hanging and locking up on this line
DoCmd.RunSQL "UPDATE clients SET salesperson = " & Text15 & " WHERE ID IN (
SELECT TOP " & NumLeads & " ID FROM clients WHERE Salesperson IS NULL And
[task note] = 'Unworked Lead' And Source = """ & CurrentSource & """) "
This code worked when I was on an access BE but now that I am trying to
update directly to SQL it no longer works.
Any ideas why?
Private Sub Command21_Click()
Dim db As DAO.Database
Dim RS As DAO.Recordset
Dim leadinfo As String
If [Howmany] = 0 Then Exit Sub
If CInt([Howmany]) > [availleads] Then Exit Sub
If [Sales Rep Name] = Null Then Exit Sub
Set db = CurrentDb()
Set RS = db.OpenRecordset("qryUnassignedOldLeads", dbOpenDynaset)
SumLeads = DSum("CountOfSource", "qryUnassignedOldLeads")
Do Until RS.EOF
Percent = RS.Fields("CountOfSource") / SumLeads
NumLeads = CInt(Percent * [Howmany])
If NumLeads = 0 Then
NumLeads = 1
End If
'RS.Fields("CountOfSource"))
CurrentSource = RS.Fields("Source")
DoCmd.SetWarnings False
leadinfo = [Text15] & " " & NumLeads & " " & CurrentSource
MsgBox leadinfo, vbOKOnly, "info to pass"
DoCmd.RunSQL "UPDATE clients SET salesperson = " & Text15 & " WHERE ID IN
( SELECT TOP " & NumLeads & " ID FROM clients WHERE Salesperson IS NULL And
[task note] = 'Unworked Lead' And Source = """ & CurrentSource & """) "
DoCmd.SetWarnings True
RS.MoveNext
Loop
End Sub
It is hanging and locking up on this line
DoCmd.RunSQL "UPDATE clients SET salesperson = " & Text15 & " WHERE ID IN (
SELECT TOP " & NumLeads & " ID FROM clients WHERE Salesperson IS NULL And
[task note] = 'Unworked Lead' And Source = """ & CurrentSource & """) "
This code worked when I was on an access BE but now that I am trying to
update directly to SQL it no longer works.
Any ideas why?