views:

1607

answers:

2

Hi,

I have a Powerpoint slide that contains textboxes. I would like to link those textboxes with a filtered view of a data table in Access.

For ex, if I had a TaskList application in Access that displayed tasks with different priorities and affectations; is there a way to open that file, select that view, and filter it according to a vba (or other) onclick button event triggered from my Powerpoint presentation?

+4  A: 

It's certainly possible to get Access data from Powerpoint.

You need to make sure you have the correct references set to theMicrosoft DAO Object Library in your VBA project.

Then, to populate your textbox in your PowerPoint presentation, you can call something like the following function, say, to return a string containing a list of Tasks matching the given TaskPriority.

Function GetTaskListFromAccess(taskPriority as Integer) as String
  Dim db As DAO.Database
  Dim rs As DAO.Recordset
  Dim listOfTasks as String

  Set db = DBEngine.OpenDatabase(“C:\my_database.accdb”)

  Set rs = db.OpenRecordset("SELECT * FROM TaskTable WHERE TaskPriority=" & _
                            taskPriority, dbOpenSnapshot)
  If not rs is nothing then
    If rs.RecordCount > 0 then
      With rs
        While Not .EOF
          if listOfTask = "" then 
            listOfTasks = !TaskName
           Else 
            listOfTasks = listOfTasks & vbCrLf & !TaskName
          End If
          .MoveNext
        Loop
      .Close
      End With
    End If
    Set rs = nothing
  End If
  Set db = nothing

  GetTaskListFromAccess = listOfTasks
End Function
Renaud Bompuis
Very minor quibble: whenever you're tempted in Access code to use "", instead try vbNullString. It's particularly important in a loop, since the memory for the Access constant is already defined, but "" has to be reallocated each time.
David-W-Fenton
Thanks for the comment, I'll keep this in mind.
Renaud Bompuis
A: 

Excelent functionality!

André Luiz Bernardes A&A - WORK, DON´T PLAY! http://al-bernardes.sites.uol.com.br/ [email protected] Brazil - Sao Paulo - Santos