Consulting

Results 1 to 9 of 9

Thread: Form from scratch

  1. #1
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    204
    Location

    Form from scratch

    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"

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

  3. #3
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    204
    Location

    Make a Form using VBA

    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.

  4. #4
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    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/Data...ess/Q_20505073
    ~Anne Troy

  5. #5
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Please post in the forum, not via emails, mud.

    Try this link instead: Click here
    ~Anne Troy

  6. #6
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Here's some code I used to use.
    [vba]
    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
    [/vba]

  7. #7
    VBAX Newbie
    Joined
    Mar 2005
    Posts
    3
    Location
    You could have a look at this.

    http://support.microsoft.com/default...b;en-us;210594

    ACC2000: Using CreateForm() and CreateReport() Functions

  8. #8
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Nobody interested in the code I posted?

    I used it to create about 20 databases.

  9. #9
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    A simple form with one textbox is equivalent to an InputBox, isn't it?
    K :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •