Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Jun 2005
    Location
    Atlanta, Georgia, USA
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts

    OLE Object (2003)

    Question regarding if I can have an excel form which is already set up as a default in an OLE object datafield. I am trying to make it where the users don't have to go through a bunch of steps to find the file and then link to the datafield. Thanks for your help.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: OLE Object (2003)

    OLE fields don't have a default value, so you'd have to do this through code behind a form., for example in the Before Insert event of the form:

    Private Sub Form_BeforeInsert(Cancel As Integer)
    With Me.OLEControl
    .Class = "Excel.Sheet"
    .SourceDoc = "C:ExcelDummy.xls"
    .Action = acOLECreateEmbed ' or acOLECreateLink
    End With
    End Sub

    where OLEControl is the name of the control and C:ExcelDummy.xls is the full path to the workbook.

  3. #3
    2 Star Lounger
    Join Date
    Jun 2005
    Location
    Atlanta, Georgia, USA
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OLE Object (2003)

    Thanks I will give it a try.

  4. #4
    2 Star Lounger
    Join Date
    Jun 2005
    Location
    Atlanta, Georgia, USA
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OLE Object (2003)

    Hans,

    After trying this, the Db didn't seem to like the path. Is it ok that it is on the network? Is it ok to put the statement on the on load property? I tried it there but it was not cooperaing either . The following is the code and the action line would light up in yellow. I have 3 ole fields in the table that I would like to have on a form and 3 excel files that are already loaded into the form in their repective fields
    Private Sub Form_Open(Cancel As Integer)
    With Me.FeeScheduleRequest
    .Class = "excel.sheet"
    .SourceDoc = "c:F1.xls"
    .Action = acOLECreateEmbed
    End With
    End Sub

    Thanks for your help.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: OLE Object (2003)

    The On Open event is not a good place for this code - it will try to put C:F1.xls into the first record. I don't think that is what you want. Moreover, On Open occurs very early, before the records are actually loaded, so trying to set a field may fail.

  6. #6
    2 Star Lounger
    Join Date
    Jun 2005
    Location
    Atlanta, Georgia, USA
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OLE Object (2003)

    Hans,


    I have attached the database and the 3 OLE object fields are at the bottom of the request form.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: OLE Object (2003)

    As I wrote, the Form_Open event occurs too early. You must do this in the On Load event:

    Private Sub Form_Load()
    RunCommand acCmdRecordsGoToNew
    With Me.FeeScheduleRequest
    .Class = "excel.sheet"
    .SourceDoc = "c:F1.xls"
    .Action = acOLECreateEmbed
    End With
    End Sub

  8. #8
    2 Star Lounger
    Join Date
    Jun 2005
    Location
    Atlanta, Georgia, USA
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OLE Object (2003)

    Hans,

    That works great. Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •