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

How do I Log Multiple Values in One Message

Midzie
P: 25
This question was split away from Deleting records from multiple tables as we don't allow multiple questions per thread - NeoPa.

I have a follow up question for Deleting records from multiple tables. I included a msgbox in every after the delete execution returning the number of records deleted in each table by inserting this code:
Expand|Select|Wrap|Line Numbers
  1. strRecordOrder = MsgBox(CStr(db.RecordsAffected) & " records from table ORDER were deleted by this SQL statement.")
  2.  
  3. strRecordSchedule = MsgBox(CStr(db.RecordsAffected) & " records from table SCHEDULE were deleted by this SQL statement.")
  4.  
  5. strRecordNote = MsgBox(CStr(db.RecordsAffected) & " records from table NOTE were deleted by this SQL statement.")
  6.  
  7. strRecordYearly = MsgBox(CStr(db.RecordsAffected) & " records from table YEARLY were deleted by this SQL statement.")
  8.  
  9. strRecordClosed = MsgBox(CStr(db.RecordsAffected) & " records from table CLOSED were deleted by this SQL statement.")
My concern now is how do I concatenate those messages so that it will be saved in my table tblLOG fieldname Remarks as like this: 2 records from table ORDER were deleted; 4 records from table SCHEDULE were deleted; 2 records from table NOTE were deleted; 100 records from table YEARLY were deleted; 150 records from table CLOSED were deleted;

Is this possible? Thanks in advance
Feb 21 '12 #1

✓ answered by ADezii

I assume you are still having problems with the Concatenation. The following Code should point you in the right direction:
Expand|Select|Wrap|Line Numbers
  1. Const conDELIMITER As String = "; "
  2. Dim strRecordOrder As String
  3. Dim strRecordSchedule As String
  4. Dim strRecordYearly As String
  5. Dim strRecordClosed As String
  6. Dim strBuild As String
  7.  
  8. strRecordOrder = CStr(db.RecordsAffected) & " records from table ORDER were deleted by this SQL statement"
  9.  
  10. strRecordSchedule = CStr(db.RecordsAffected) & " records from table SCHEDULE were deleted by this SQL statement"
  11.  
  12. strRecordNote = CStr(db.RecordsAffected) & " records from table NOTE were deleted by this SQL statement"
  13.  
  14. strRecordYearly = CStr(db.RecordsAffected) & " records from table YEARLY were deleted by this SQL statement"
  15.  
  16. strRecordClosed = CStr(db.RecordsAffected) & " records from table CLOSED were deleted by this SQL statement"
  17.  
  18. strBuild = strRecordOrder & conDELIMITER & strRecordSchedule & conDELIMITER & strRecordNote & _
  19.            conDELIMITER & strRecordYearly & conDELIMITER & strRecordClosed

Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,487
At the time that you display these values you also need to save them in separate variables. When all are done and you're ready to log the details, simply formulate a message using all of the variables and log it.
Feb 21 '12 #2

ADezii
Expert 5K+
P: 8,634
I assume you are still having problems with the Concatenation. The following Code should point you in the right direction:
Expand|Select|Wrap|Line Numbers
  1. Const conDELIMITER As String = "; "
  2. Dim strRecordOrder As String
  3. Dim strRecordSchedule As String
  4. Dim strRecordYearly As String
  5. Dim strRecordClosed As String
  6. Dim strBuild As String
  7.  
  8. strRecordOrder = CStr(db.RecordsAffected) & " records from table ORDER were deleted by this SQL statement"
  9.  
  10. strRecordSchedule = CStr(db.RecordsAffected) & " records from table SCHEDULE were deleted by this SQL statement"
  11.  
  12. strRecordNote = CStr(db.RecordsAffected) & " records from table NOTE were deleted by this SQL statement"
  13.  
  14. strRecordYearly = CStr(db.RecordsAffected) & " records from table YEARLY were deleted by this SQL statement"
  15.  
  16. strRecordClosed = CStr(db.RecordsAffected) & " records from table CLOSED were deleted by this SQL statement"
  17.  
  18. strBuild = strRecordOrder & conDELIMITER & strRecordSchedule & conDELIMITER & strRecordNote & _
  19.            conDELIMITER & strRecordYearly & conDELIMITER & strRecordClosed
Feb 21 '12 #3

Midzie
P: 25
Hi Neopa/ADezii,

Earlier I made this code that's why it only returned and recorded 1; 1; 1; 1; 1; in my tblLog:
Expand|Select|Wrap|Line Numbers
  1. strRecord = strRecordOrder & strRecordSchedule & strRecordNote & strRecordYearly & strRecordClosed
I added the conDelimiter and it is working now:-) Thanks to both of you. I still added this code to return the number of records deleted in a message box:
Expand|Select|Wrap|Line Numbers
  1. MsgBox CStr(db.RecordsAffected) & " records from table Order were deleted by this SQL statement."
Feb 22 '12 #4

Post your reply

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