Generating Forms

  • Thread starter Thread starter dbracey
  • Start date Start date
D

dbracey

Is it possible to generate forms or at least part of a form from code
within Access?

I am dealing with a variable number of entries that can't have NULL
values. If I can prompt the user for the number of items they will be
entering, can I then generate a form containing the proper number of
items for entry?

If so, how would I go about doing it?

Thanks in advance,
 
Here is some code that will generate a form and insert
some fields.
*****************************************************
Private Sub Build_Form_Click()
Dim frm As Form
Dim ctlField1 As Control, ctlField2 As Control, ctlField3
As Control

Set frm = CreateForm
frm.RecordSource = "SELECT SrVols.LastName,
SrVols.FirstName, " & _
"SrVols.email FROM SrVols WHERE (((SrVols.email) Is
Not Null));"
DoCmd.Restore
With frm
.DefaultView = 1 'Continuous form view
.Caption = "Email Addresses"
.PopUp = True
.Modal = True
.AllowFormView = True
.AllowDatasheetView = True
.AllowPivotChartView = False
.AllowPivotTableView = False
.DividingLines = False
.Width = 4600
.AutoResize = True
.AutoCenter = True
.BorderStyle = 3
.ControlBox = True
.MinMaxButtons = 0
End With

frm.Section(acDetail).Height = 300
Set ctlField1 = CreateControl(frm.Name, acTextBox,
acDetail, _
"Last Name", "LastName", 100, 50, 2200)
Set ctlField2 = CreateControl(frm.Name, acTextBox,
acDetail, _
"First Name", "FirstName", 2880, 50, 2200)
Set ctlField3 = CreateControl(frm.Name, acTextBox,
acDetail, _
"Email Address", "email", 5760, 50, 2200)
DoCmd.Restore
DoCmd.OpenForm frm.Name, acNormal

End Sub
*****************************************************
Hope this is a help.

But wouldn't it be easier to have a set form and add a
default value to any NULL fields before update?
 
Back
Top