Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql string help

Status
Not open for further replies.

koukouroukou

Programmer
Feb 6, 2002
38
GR
MY SQL STRING GOES LIKE THIS
SELECT TOP 50 FROM CUST WHERE CALLTRIGER = 0
LETS SAY THA THE 1ST USER TAKES THESE 50 RECORDS.
HOW THE SECOND USER WILL SELECT NEXT 50?
THANKS ON ADVANCE

 
Everyone who runs this query will get the same 50 records (assuming no inserts or deletes) but I imagine you have discovered that.


What is your purpose in wanting to do this? JHall
 
my proplem was to be certain that each users would have unique rows with an sql statement without saying
select * from cust where custid < 1000. I solved my problem using ADO.


Option Compare Database
Option Explicit
Public Sub custrst()
On Error GoTo ermsg
'=================================================================================
'filter records and split it to agents procedure
'=================================================================================


Dim rst As ADODB.Recordset
Dim apd As ADODB.Recordset
Dim calltriesF As String
Dim callresultF1 As String
Dim callresultF2 As String
Dim callresultF3 As String
Dim callresultF4 As String
Dim callresultF5 As String
Dim recs As String
Dim no As String


'=================================================================================
'values
'=================================================================================
recs = Forms!values!totalrecords
calltriesF = Forms!values!setcalltries
callresultF1 = Forms!values!result1
callresultF2 = Forms!values!result2
callresultF3 = Forms!values!result3
callresultF4 = Forms!values!result4
callresultF5 = Forms!values!result5

DoCmd.SetWarnings False

no = Forms!onlineagent!Agentonlineid.Value
'=================================================================================
'recordset for temp
'=================================================================================

Set apd = New ADODB.Recordset

With apd
Set .ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockPessimistic
.Source = &quot;temp&quot;
.Open options:=adCmdTable
End With

'=================================================================================
'recordset for cust
'=================================================================================

Set rst = New ADODB.Recordset

With rst
Set .ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockPessimistic
.Source = &quot;cust&quot;
.Open &quot;SELECT * FROM cust WHERE &quot; & _
&quot;[calltries]< '&quot; & calltriesF & &quot;' AND&quot; & _
&quot;([result]='&quot; & callresultF1 & &quot;' OR&quot; & _
&quot;[result]='&quot; & callresultF2 & &quot;' OR&quot; & _
&quot;[result]='&quot; & callresultF3 & &quot;' OR&quot; & _
&quot;[result]='&quot; & callresultF4 & &quot;' OR&quot; & _
&quot;[result]='&quot; & callresultF5 & &quot;')&quot; & _
&quot;ORDER BY result, calltries&quot;


'=================================================================================
'records by user
'=================================================================================


.AbsolutePosition = ((no - 1) * recs) + 1
Do Until .AbsolutePosition = (no * recs) + 1

'append sto temp
apd.AddNew
apd.Fields(0) = .Fields(0) 'custid
apd.Fields(1) = .Fields(1) 'name
apd.Fields(2) = .Fields(2) 'surname
apd.Fields(3) = .Fields(3) 'fathers
apd.Fields(4) = .Fields(4) 'adt
apd.Fields(5) = .Fields(5) 'afm
apd.Fields(6) = .Fields(6) 'birthdate
apd.Fields(7) = .Fields(7) 'street
apd.Fields(8) = .Fields(8) 'no
apd.Fields(9) = .Fields(9) 'letter
apd.Fields(10) = .Fields(10) 'province
apd.Fields(11) = .Fields(11) 'city
apd.Fields(12) = .Fields(12) 'postalcode
apd.Fields(13) = .Fields(13) 'phone1
apd.Fields(14) = .Fields(14) 'phone2
apd.Fields(15) = .Fields(15) 'phone3
apd.Fields(16) = .Fields(16) 'email
apd.Fields(17) = .Fields(17) 'result
apd.Fields(18) = .Fields(18) 'calltries
apd.update
rst.MoveNext

Loop

End With
rst.close
Set rst = Nothing
Exit Sub

ermsg:
MsgBox &quot;********************&quot;

End Sub

and i put the records im interested in a temp table
Thanks anyway man
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top