# Database Discussions > Microsoft Access >  Programmatically create a form using VBA

## nickg96

Hi,

I'm using MS Access 2000, and I need to a form that consists of dynamic objects (i.e., the objects (text boxes) in the form are dependent upon data, and may need to change)

Example- The form is illustrating the client's current currency positions. I may need more text boxes in the form if its recordsource increases that types of currency the client possesses. Thus, it the client decides to increase the types of currency's he/she trades, I need the form to dynamically create a new field illustrating that currency. 

Using VBA, is there a way to programmatically create a form, so it can store dynamic objects/content? 

Please let me know if I have not explained this in great enough detail

I'd appreciate any help at all,

Thanks

----------


## Donall

I happened to be reading the programing manual for access 97 yesterday and came across the following section of code that creates a form with a number of controls to use in one of its examples. It might give you a few ideas.

"Enter the following code in a standard module and save the module. This function creates a new form with an empty unbound object frame.

Function CreateFormWithFrame(strControlName As String)
   Dim frm As Form, ctlFrame As Control, ctlCommand As Control
   Dim intLeft As Integer, intRight As Integer
   Set frm = CreateForm
   Set ctlFrame = CreateControl(frm.Name, acObjectFrame)
   intLeft = ctlFrame.Left + ctlFrame.Width + 200
   intRight = 200
   Set ctlCommand = CreateControl(frm.Name, acCommandButton, , , , _
      intLeft, intRight)
   With ctlCommand
      .Name = strControlName
      .Caption = strControlName
      .OnClick = "[Event Procedure]"
   End With
   DoCmd.Restore
End Function

----------


## nickg96

cool, thanks for the help!

----------

