Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Maidstone, Kent, England
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CreateContol in remote DB (A97)

    I have been trying to write a procedure to update a form in a second database.
    I have been able to reference the remote db OK and open the form in design mode but cannot work out how to then reference the form in CreateControl!

    The relevant part of the code is

    <pre>Sub NewBtn()
    Dim frm As Form
    Dim ctlBtn As Control
    Dim lngLine As Long
    Dim mdl As Module
    Dim strForm As String
    Dim AccessApp As New Access.Application
    Dim strDB As String

    strForm = "Form1"
    strDB = "CbFrontEndsdb1.mdb"
    AccessApp.OpenCurrentDatabase strDB
    AccessApp.DoCmd.OpenForm strForm, acDesign
    Set frm = AccessApp.Forms(strForm)
    Set mdl = frm.Module
    Set ctlBtn = CreateControl(frm.Name, acCommandButton, , "", "", 2500, 1000, 1000, 400)
    .....................
    </pre>


    I was hoping that frm.Name would give me the reference to the remote form but generates the error

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

    Re: CreateContol in remote DB (A97)

    Use AccessApp.CreateControl. Otherwise, Access assumes that you want to create a control in the database that is running the code.

  3. #3
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Maidstone, Kent, England
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CreateContol in remote DB (A97)

    Thanks Hans,

    I will get the hang of this one day!! <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Peter

Posting Permissions

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