• CreateContol in remote DB (A97)

    Author
    Topic
    #382588

    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

    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 = "C:DbFrontEndsdb1.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)
    .....................
    

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

    Viewing 0 reply threads
    Author
    Replies
    • #649150

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

      • #649174

        Thanks Hans,

        I will get the hang of this one day!! smile

        Peter

    Viewing 0 reply threads
    Reply To: CreateContol in remote DB (A97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: