Solved Outlook Appointment Subform records (1 Viewer)

Juett

Registered User.
Local time
Today, 23:18
Joined
Jul 16, 2019
Messages
71
Hi All,

I have a main form with a subform and I want to insert all records from the subform into an Outlook appointment/calendar entry. Everything works accept how the subfrom records are copied. I use the following code to grab the subform records:

Code:
Private Sub Outlook_Click()
 Dim rs As DAO.Recordset
 Set rs = Forms!Main!FrmSub.Form.RecordsetClone
 Dim strBody As String, i As Integer
strBody = strBody
rs.MoveFirst
Do Until rs.EOF
strBody = strBody
  For i = 0 To rs.Fields.Count - 1
   strBody = strBody & rs.Fields(i)
  Next
  strBody = strBody & vbCr
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
strBody = strBody

The above code works, but it copies every single field from the underlying table for each record with out spaces, for example:

587 169 11234 Ford Focus Used
586 169 5678 Mercedes SLK New

I'd like to specify which fields to include, so the results look like this (columns/fields 1,2 and 6 removed/ignored):

1234 Ford Focus
5678 Mercedes SLK

I'm sure I've missed something simple relating to specifying the columns, but can't seem to figure out what it is.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:18
Joined
May 21, 2018
Messages
8,529
Code:
For i = 0 To rs.Fields.Count - 1
   if not (i = 0 or i = 1 or i = 5) then
      strBody = strBody & rs.Fields(i)
   end if
Next

Assume you mean 1,2,6 columns.
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:18
Joined
Sep 21, 2011
Messages
14,310
StrBody = strBody ?
 

Users who are viewing this thread

Top Bottom