Search notes:

Access Object Model: application.createForm

This is supposed to be a rudimentary code fragment that demonstrates how a form can be dynamically created with VBA with the object model of MS-Access.
function createDBQueryForm() as access.form ' {

   set createDBQueryForm = access.createForm

   createDBQueryForm.width                    = 6900
   createDBQueryForm.section(acDetail).height = 5600
   createDBQueryForm.popup                    =  true

   dim frmNameOrig as string
   frmNameOrig = createDBQueryForm.name

   dim ctrlInput as control
   set ctrlInput = createControl(frmNameOrig, acTextBox)
   with ctrlInput
     .width           =  6300
     .height          =  5000
     .left            =   300
     .top             =   300
     .name            = "txtSQL"
     .fontName        = "Consolas"
     .fontSize        =  10
     .enterKeyBehavior=  true
     .width           =  6300
     .height          =  5000
     .left            =   300
     .top             =   300
     .name            = "txtSQL"
     .fontName        = "Consolas"
     .fontSize        =  10
     .enterKeyBehavior=  true

   end With

   doCmd.close acForm, frmNameOrig, acSaveYes

   doCmd.rename "frmQueryDB", acForm, frmNameOrig

end function  ' }

sub main() ' {

    dim f as access.form
    set f = createDBQueryForm

end sub ' }

Index