Pulling random info excluding specified date range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Need some help with this one. My manager has a customer list and wants to pull random customers (10-15), along with their info, for sending out customer satisfaction surveys. But he also want's to be able to exclude a certin time frame, like the previous month or two. There is a date colum on when that customer was last sent one. I have a feeling that this is going to take some VB programing that I don't know, or can it be done in a query?
 
There have been several answers to this general type of question recently.
Search this group, and probably formscoding using Google group search:

http://groups.google.com/groups?hl=...eta=group=microsoft.public.access.formscoding

Getting the list of customers to select from is easy, just write a query
with criteria to select the data range etc you want.
You will need some VBA code, maybe something like this will give you a
start, from one of my earlier posts:

Fill a temporary table with your customer numbers, in the range you want,
and select one of them at random. After that one is used, remove it from
the table and call the function again to select the next one. This way you
can select the range of numbers returned, just by putting that range in the
table initially.

Something like ( aircode )

Function GetRandomNo() As Long

Dim rRecord As Long
Dim endnum As Long

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tblRandom")
Randomize Timer 'seed random number generator
rs.Edit
rs.MoveLast 'ensure recordcount is updated
endnum = rs.RecordCount 'get recordcount
rs.MoveFirst
rRecord = endnum * Rnd(1) 'get random number between 0 and end of table
rs.Move rRecord 'move to that record
GetRandomNo = rs!rNumber 'get number from that record
rs.Delete 'delete number from table

rs.Close
Set rs = Nothing
End Function



--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
Chaz said:
Need some help with this one. My manager has a customer list and wants to
pull random customers (10-15), along with their info, for sending out
customer satisfaction surveys. But he also want's to be able to exclude a
certin time frame, like the previous month or two. There is a date colum on
when that customer was last sent one. I have a feeling that this is going to
take some VB programing that I don't know, or can it be done in a query?
 
Back
Top