Divide Output from Query

juneau730

Board Regular
Joined
Jun 7, 2018
Messages
111
Morning all,

Not sure if what I am attempting to do, is doable or not, but I wasn't able to find anything.

I have a query that pulls 3 columns from the master table. Depending on what department I pull the data from, the results quantity varies.

What I would like to be able to do, if possible, is split the data into 3rds. Basically I would have 3 separate forms created from this query, with a 3rd of the data from the master table on each form.
 
we send 3 different phishing emails during each exercise
I have to wonder what is meant by "phishing emails". If it's the sort of thing that seeks to get my personal/financial information, why would anyone provide assistance to that effort? If that's what this is about, the whole thread should be deleted. I must be missing something...
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
I have to wonder what is meant by "phishing emails". If it's the sort of thing that seeks to get my personal/financial information, why would anyone provide assistance to that effort? If that's what this is about, the whole thread should be deleted. I must be missing something...
Yes, that is what a "phishing email" is, it's an attempt to gains personal and/or financial information.

Please explain why my thread should be deleted? This is an exercise/campaign that is conducted at my place of employment, as well as many other employers where sensitive data is regularly used, accessed and stored, used to track, train and educate staff what to look for in real life. Everything is done legally and above board, using federally approved test methods and applications.

Google Cofense PhishMe
 
Upvote 0
My friend gets these test emails in work all the time, in amongst real emails, which he also marks as phishing.
Never can be too careful. :)
I might use a letter from the name, first run use the second letter to sort on, second run use the thrid letter to sort on, to get a different order. Keep track of the index of the last character used. If last name too short then use first name. A dedicated function would probably help here.
Then find the sumber of records, divide by 3 and process accordingly.
 
Upvote 0
If it is simple, then please provide some code
I'd like to provide the code, but that only makes sense if OP is willing to add a field to the original table. OP hasn't responded to my post yet. I await his response.
 
Upvote 0
I have to wonder what is meant by "phishing emails". If it's the sort of thing that seeks to get my personal/financial information, why would anyone provide assistance to that effort? If that's what this is about, the whole thread should be deleted. I must be missing something...
My workplace does these exercises all the time too, since we deal with a lot of PHI. They want to make sure that people follow the proper protocol when dealing with external emails with links, so occasionally sends out tests.

The question itself, splitting an Access list into 3 equal parts could be used for many things, in and of itself is very general and could be used for any number of reasons. Nowhere in this request are they asking for assistance then emailing that list or anything like that. So there is nothing wrong with this question.
 
Upvote 0
Here's a routine to show how you might divide a recordset into thirds randomly.
-Make a recordset from your table, order it randomly on some field.
-Process this already random recordset by moving each third to a known location
-Thi sample just outputs to immediate window.
VBA Code:
' ----------------------------------------------------------------
' Procedure Name: testthirds
' Purpose: Sample routine to divide a recordset into thirds for further processing
'   This sample prints info from the table, but you could adapt to create lists or files...
' Procedure Kind: Sub
' Procedure Access: Public
' Author: Jack
' Date: 03-Dec-23
'
'Sample table design
'table_name  field_name   field type
'EmpsTable       DeptNo    Long Integer
'EmpsTable       EmpNo     Long Integer
'EmpsTable       FName     Text
'EmpsTable       ID        AutoNumber
'EmpsTable       Lname     Text
'EmpsTable       SAL       Double


' ----------------------------------------------------------------
Sub testthirds()
          Dim db As DAO.Database
          Dim i As Long
          Dim j As Long
          Dim cnt As Long      'to hold recordcount
          Dim strtCnt As Long  'to identify start of next third of records
          Dim rs As DAO.Recordset
10        Set db = CurrentDb
          Dim SQL As String
          ' my sample table stored as a recordset randomly ordered on empno
20        SQL = "Select fname,lname,empno from empstable order by rnd(empno);"
30        Set rs = db.OpenRecordset(SQL)
40        cnt = rs.RecordCount
50        Do Until rs.EOF
60        strtCnt = 1
70        For j = 1 To 3   'this sample deals with thirds
80            For i = strtCnt To (cnt / 3) * j
90                Debug.Print i; rs!FName & " " & rs!LName
100               rs.MoveNext
110           Next i
120           Debug.Print
130           strtCnt = i
140       Next j
150       Loop
160       rs.Close
170       db.Close
End Sub
 
Upvote 0
I'd like to provide the code, but that only makes sense if OP is willing to add a field to the original table. OP hasn't responded to my post yet. I await his response.
Sorry for the delay.
I'm willing to add a field to the master table and see if it performs the function needed.
However, if this is something that works have to be done manually every time the data is refreshed, it would defeat the purpose.
 
Upvote 0
Here's a routine to show how you might divide a recordset into thirds randomly.
-Make a recordset from your table, order it randomly on some field.
-Process this already random recordset by moving each third to a known location
-Thi sample just outputs to immediate window.
VBA Code:
' ----------------------------------------------------------------
' Procedure Name: testthirds
' Purpose: Sample routine to divide a recordset into thirds for further processing
'   This sample prints info from the table, but you could adapt to create lists or files...
' Procedure Kind: Sub
' Procedure Access: Public
' Author: Jack
' Date: 03-Dec-23
'
'Sample table design
'table_name  field_name   field type
'EmpsTable       DeptNo    Long Integer
'EmpsTable       EmpNo     Long Integer
'EmpsTable       FName     Text
'EmpsTable       ID        AutoNumber
'EmpsTable       Lname     Text
'EmpsTable       SAL       Double


' ----------------------------------------------------------------
Sub testthirds()
          Dim db As DAO.Database
          Dim i As Long
          Dim j As Long
          Dim cnt As Long      'to hold recordcount
          Dim strtCnt As Long  'to identify start of next third of records
          Dim rs As DAO.Recordset
10        Set db = CurrentDb
          Dim SQL As String
          ' my sample table stored as a recordset randomly ordered on empno
20        SQL = "Select fname,lname,empno from empstable order by rnd(empno);"
30        Set rs = db.OpenRecordset(SQL)
40        cnt = rs.RecordCount
50        Do Until rs.EOF
60        strtCnt = 1
70        For j = 1 To 3   'this sample deals with thirds
80            For i = strtCnt To (cnt / 3) * j
90                Debug.Print i; rs!FName & " " & rs!LName
100               rs.MoveNext
110           Next i
120           Debug.Print
130           strtCnt = i
140       Next j
150       Loop
160       rs.Close
170       db.Close
End Sub
Sorry for the delay, thanks, I'll give it a try.
 
Upvote 0
Sorry for the delay.
I'm willing to add a field to the master table and see if it performs the function needed.
However, if this is something that works have to be done manually every time the data is refreshed, it would defeat the purpose.
You should only need to add the field to the master table once.
Once you add it to the table, that field is there, and the code he gave you can use it.
 
Upvote 0
XPS35,

If you're willing to provide the code, I'm willing to give it a try and to add some data to the table
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top