PDA

View Full Version : Form from scratch



mud2
04-01-2005, 05:59 PM
Can someone please give me an example of how to create a simple form, with one text box?
And...How to use the "Template" suggested in microsoft's so-called "Help"

Paleo
04-01-2005, 08:23 PM
Hi,

you can find what you want at:

http://www.microsoft-accesssolutions.co.uk/login.htm
http://mis.bus.sfu.ca/tutorials/MSAccess/tutorials/forms.pdf
http://polaris.umuc.edu/~acarswel/ADMN640/AccessDataEntryForm.html

mud2
04-01-2005, 10:26 PM
I guess I'm not making myself clear...I'd like a sample of the VBA necessary to make a simple Form with one text box.

Anne Troy
04-02-2005, 12:59 AM
No need to post a new thread, mud. I've moved your post to your previous thread.

So what you want to do is create the form using VBA, not create a form that uses VBA, is that correct? Like, you want the VBA procedure to be run and it creates a form?

If yes... http://www.experts-exchange.com/Databases/MS_Access/Q_20505073

Anne Troy
04-02-2005, 09:06 AM
Please post in the forum, not via emails, mud.

Try this link instead: Click here (http://www.experts-exchange.com/Databases/MS_Access/Q_20505073.html)

Norie
04-02-2005, 11:28 AM
Here's some code I used to use.

Public Const TW = 567
Public Sub NewForm()
'creates a new standard form based on a blank template
'asking user if they want standard buttons such as help & back
'and if they want any other additional buttons of two standard
'sizes - big 6cmx1cm and small 3cmX0.667cm
Dim frm As Form, ctl As Control, mdl As Module
Dim NoControls%
Dim I%
Dim X%, Y%
Dim lngReturn As Long
Dim R$
Y = 0
X = 0
Set frm = CreateForm(, "Blank Form")
frm.Caption = InputBox("What caption do you want for the the form?", "Form Caption")

Set ctl = CreateControl(frm.Name, acLine, , , , 0, 11 * TW, 20 * TW)
ctl.SpecialEffect = 3
If MsgBox("Do you want a back button?", vbYesNo + vbQuestion, "Back button?") = vbYes Then
R$ = InputBox("Enter name of form to go back to", "Back form")
Set ctl = CreateControl(frm.Name, acCommandButton, _
, , , 1 * TW, 11.2 * TW, 3 * TW, 0.667 * TW)
ctl.Caption = "&Back"
ctl.Name = "btnBack"

Set mdl = frm.Module
lngReturn = mdl.CreateEventProc("Click", ctl.Name)
mdl.InsertLines lngReturn + 1, vbTab & "Swapforms " & Chr(34) & R$ & Chr(34) & ", Me.FormName"
End If
If MsgBox("Do you want a help button?", vbYesNo + vbQuestion, "Help button?") = vbYes Then
Set ctl = CreateControl(frm.Name, acCommandButton, _
, , , 16 * TW, 11.2 * TW, 3 * TW, 0.667 * TW)
ctl.Caption = "&Help"
ctl.Name = "btnHelp"
Set mdl = frm.Module
lngReturn = mdl.CreateEventProc("Click", ctl.Name)

mdl.InsertLines lngReturn + 1, vbTab & "Msgbox " & Chr(34) & _
"There is no help file currently available" & Chr(34) & ", vbInformation, ""Help"""
End If

NoControls = InputBox("How many large buttons do you want " & _
"on the new form?", "Large buttons")
For I = 1 To NoControls
Set ctl = CreateControl(frm.Name, acCommandButton, _
, , , X, Y, 6 * TW, 1 * TW)
ctl.Name = "btnLNew" + Trim(Str(I))
X = X + TW * 6.5
If X > (TW * 14) Then X = 0: Y = Y + TW * 1.5
Next I
X = 0
Y = Y + TW * 1.5
NoControls = InputBox("How many small buttons do you want " & _
"on the new form?", "Small buttons")
For I = 1 To NoControls
Set ctl = CreateControl(frm.Name, acCommandButton, _
, , , X, Y, 3 * TW, 0.667 * TW)
ctl.Name = "btnSNew" + Trim(Str(I))
X = X + TW * 3.5
If X > (TW * 17) Then X = 0: Y = Y + TW * 1.5
Next I
MsgBox "Back & Help buttons have been created with standard " & _
"code associated with them!", vbInformation, "Finished"
DoCmd.Maximize
End Sub

Tanis
04-05-2005, 07:47 AM
You could have a look at this.

http://support.microsoft.com/default.aspx?scid=kb;en-us;210594

ACC2000: Using CreateForm() and CreateReport() Functions

Norie
04-05-2005, 05:28 PM
Nobody interested in the code I posted?

I used it to create about 20 databases.

Killian
04-05-2005, 06:09 PM
A simple form with one textbox is equivalent to an InputBox, isn't it?