Creating a new form using vba code only .... any ideas

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

I want to create a form using vba

Iv'e got Dim frm as new form. but some of the design time tools such as create object do not work.

It appeqrs that when you invote a new form it's live and not in design view.

any ideas of how to do it.

Thanks in advance Russ
 
Hi Russ,

Copy and paste this code to a new standard module and run
it right from the immediate window. It will create a new
form with a very pleasant label and save it.

You should be able to study the code and see what is going
on. Also look in the Help files for CreateForm and
CreateControl for other samples.

Public Function funcCreateForm()
On Error GoTo ErrorPoint

Dim frm As Form
Dim ctlLabel As Control

' Create the form and set properties
Set frm = CreateForm
frm.Caption = "Access Junkie"
frm.AutoCenter = True
frm.NavigationButtons = 0
frm.RecordSelectors = 0
frm.ScrollBars = 0
frm.Width = 5760
frm.Section(0).Height = 2880
frm.Section(0).BackColor = -2147483633
frm.AllowEdits = False
frm.AllowDeletions = False
frm.AllowAdditions = False
frm.AllowFilters = False
frm.ShortcutMenu = False
frm.ViewsAllowed = 0

' Create the label
Set ctlLabel = CreateControl(frm.Name, acLabel, _
, , "Access Junkies Rule The World!", 1440, 720, 2880)

' Save and close the form
DoCmd.Close acForm, frm.Name, acSaveYes

ExitPoint:
Exit Function

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " _
& Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Function

--
Jeff Conrad
Access Junkie
Bend, Oregon
-----Original Message-----


Hi all,

I want to create a form using vba.

Iv'e got Dim frm as new form. but some of the
design time tools such as create object do not work.
It appeqrs that when you invote a new form
it's live and not in design view..
 
Back
Top