By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,314 Members | 1,539 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,314 IT Pros & Developers. It's quick & easy.

having Trouble With Report

P: 5
Could someone explain what I doing wrong?

I created a data base in access which contain all the employees who have cell phones.

the report gives me all the call made per employee , grouping them by employee numbers which works fine.
I'm am trying to write a looping code that wiil seperate each employee statement and email automatically only thier portion of the report. I setup up the macro to sendout, but it is sending all employees the full report.

Please help!!!!!!!!!!!!!
Jan 29 '08 #1
Share this Question
Share on Google+
3 Replies


JustJim
Expert 100+
P: 407
Could someone explain what I doing wrong?

I created a data base in access which contain all the employees who have cell phones.

the report gives me all the call made per employee , grouping them by employee numbers which works fine.
I'm am trying to write a looping code that wiil seperate each employee statement and email automatically only thier portion of the report. I setup up the macro to sendout, but it is sending all employees the full report.

Please help!!!!!!!!!!!!!
Easy on the exclamation marks there good buddy (a lot of people think that overuse of exclamation marks indicates instability, my theory is that it is the little !'s themselves that drive you nuts, the more you use, the more likely it is that you will start to wear your underwear on your head... just a thought)

Anyway, post the code you've got that sends to everybody and we'll have a look and see if we can fix it for you.

Jim
Jan 30 '08 #2

P: 5
Thanks Jim and I promise to take it easy on the !.
Here in the code:
Sub RecordSetDemo()
'Create a Recordset containing all fields and records from the Emplyee Cellular Phone Useage table'
Dim myConnection As ADODB.Connection
Dim myRecordSet As New ADODB.Recordset
Set myConnection = CurrentProject.Connection
myRecordSet.ActiveConnection = myConnection
myRecordSet.Open "Emplyee Cellular Phone Useage", , adOpenStatic
'At this point myRecordset refers to the Emplyee Cellular Phone Useage table

myRecord.MoveFirst 'Go to first record in Emplyee Cellular Phone Useage table.

'The loop below prints the contents of the First field from each record.
While Not myRecordSet.EOF 'Top of Loop.
Debug.Print myRecordSet.Fields(1).Value
myRecordSet.MoveNext 'Move to next record in recordset
Wend 'Bottom of loop

Debug.Print "All Done!" 'This line not reached until loop is doen.

'Close and clean up.
myRecordSet.Close
Set myRecordSet = Nothing
Set myConnection = Nothing

End Sub
Jan 30 '08 #3

JustJim
Expert 100+
P: 407
Thanks Jim and I promise to take it easy on the !.
Here in the code:
Expand|Select|Wrap|Line Numbers
  1. Sub RecordSetDemo()
  2. 'Create a Recordset containing all fields and records from the Emplyee Cellular Phone Useage table'
  3. Dim myConnection As ADODB.Connection
  4. Dim myRecordSet As New ADODB.Recordset
  5. Set myConnection = CurrentProject.Connection
  6. myRecordSet.ActiveConnection = myConnection
  7. myRecordSet.Open "Emplyee Cellular Phone Useage", , adOpenStatic
  8. 'At this point myRecordset refers to the Emplyee Cellular Phone Useage table
  9.  
  10. myRecord.MoveFirst 'Go to first record in Emplyee Cellular Phone Useage table.
  11.  
  12. 'The loop below prints the contents of the First field from each record.
  13. While Not myRecordSet.EOF 'Top of Loop.
  14.     Debug.Print myRecordSet.Fields(1).Value
  15.     myRecordSet.MoveNext        'Move to next record in recordset
  16. Wend                        'Bottom of loop
  17.  
  18. Debug.Print "All Done!" 'This line not reached until loop is doen.
  19.  
  20. 'Close and clean up.
  21. myRecordSet.Close
  22. Set myRecordSet = Nothing
  23. Set myConnection = Nothing
  24.  
  25. End Sub
You could do some testing inside your While...Wend loop to see which records you would use (in this case Debug.Print) but the more efficient method would be to be more choosy about which records go into the recordset in the first place.

The easiest way would be to write a query to select just those records you want from the Emplyee Cellular Phone Useage table and open the record set on the query not on the whole table.

Jim
Jan 31 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.