views:

450

answers:

3

Hey guys. I have a form that I intend to allow users to browse powerpoint presentations through, because there are a lot of different briefs for metrics, which is what I use this database for. So, I already know how to set up everything, just got one little hang up.

If I place a combo box on the form to select from a list of different presentation, can I use that in the file path string (that I have to use to pull the ppt into theobject frame in access.

example:

"C:\Users\Justin\Desktop\" & cmbTitle & ".ppt"

I tried it and it gives me the error message variable not defined. I never defined a control before on in these things, would it be as a string?

I realize that the exact file path much match the entered value. Access 2000-2003/XP

Thanks as always guys!

+2  A: 

You need to refer to the field as Me.cmbTitle. As it is written, it looks like you're calling the variable cmbTitle which doesn't exist.

David Walker
While I think it's best practice to specify the parent of cmbTitle (though I'd use Me!cmbTitle instead of Me.cmbTitle, which is dependent on Access/VBA behind the scenes creating hidden property wrappers that allow controls to be treated as properties of the form; this has the one advantage of compile-time validation), it shouldn't be necessary, so something else seems to be going on.
David-W-Fenton
that actually did the trick. don't know what i was thinking not adding me. in front of it! thanks though!
Justin
+1  A: 

Is the value of cmbTitle some ID/Integer field or is it the actual string value? You may want to use the immediate window to check this. Also, make sure the value of cmbTitle doesn't have any backslashes or spaces (That may require quotes?).

Jeff O
+1  A: 

I'm somewhat confused as to what you're trying to do. I will write my answer assuming:

  1. you have a form in an Access database.

  2. on that form is combo box that lists the PowerPoint presentations your users are working with.

  3. the bound column of the combo box lists the filename (without path) of each PPT file.

  4. when the user selects a filename from the combo box, you want to display it in an unbound OLE object frame.

The code for that, assuming the list of PPT files is called cmbTitle, would be in the combo box's AfterUpdate event and would look like this:

  Private Sub cmbTitle_AfterUpdate()
    Dim strPresentation As String

    If IsNull(Me!cmbTitle) Then Exit Sub
    strPresentation = "C:\Users\Justin\Desktop\" & Me!cmbTitle & ".ppt"
    Me!olePPT.SourceDoc = strPresentation
  End Sub

Now, I can't get a test unbound OLE object frame to work with this, but it seems to me to be the right way to do it.

My suspicion is that you're either attempting to set the wrong property, or you've defined your OLE frame wrongly, but I can't offer any more advice on that without knowing more about what you're actually attempting to do, and exactly what line of code is causing the error.

David-W-Fenton
yeah i should have posted the whole thing. i am new to this in so many ways. the compile error was "variable not defined" but i had forgotten to put "me!" or "me." infront of the cmbTitle. As soon as I did it worked fine. I will still post the whole code though because I am sure there is more advice I sure do need/appreciate! Thanks
Justin
Strange. Access usually does fine without the parent reference.
David-W-Fenton