+ Reply to Thread
Results 1 to 16 of 16

Create User Forms of "The Course Booking Form"

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    01-02-2004
    Location
    malaysia
    Posts
    342

    Create User Forms of "The Course Booking Form"

    Hi,
    I have a little knowledge of Excel Programming and I am seeking advice and help. With reference to the http://www.exceltip.com/st/Create_Us...Excel/629.html, I managed to create the form but I somehow couldn’t get it executed. Can someone please help me? Attached herewith my file for evaluation. Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Place this code in an Standard Module

    Sub ShowDorm()
    frmCourseBooking.Show
    End Sub
    Add a button grom the Forms Toolbar & then assign the macro to it.

    The code below is an alternative way of coding the Form that I wrote a while ago.
    Option Explicit
    '---------------------------------------------------------------------------------------
     ' Module    : Module1
     ' DateTime  : 09/05/2007 08:43
     ' Author    : Roy Cox (royUK)
     ' Website   :  Click here for more examples and Excel Consulting
     ' Purpose   : Illustrate the principles of UserForm design and the associated VBA coding.
     ' Disclaimer; This code is offered as is with no guarantees. You may use it in your
     '             projects but please leave this  header intact.
     
     '---------------------------------------------------------------------------------------
    Option Explicit
    Private Sub chkLunch_Change()
        chkLunch = chkVegetarian.Enabled
        chkVegetarian = chkLunch
        chkVegetarian.Enabled = chkLunch
    End Sub
    Private Sub cmdCancel_Click()
        Unload Me
    End Sub
     
    Private Sub cmdClearForm_Click()
        Call UserForm_Initialize
    End Sub
     
    Private Sub cmdOK_Click()
         'no need to activate the  sheet
        Dim wsData As Worksheet
        Dim rNextCl As Range
         'sheet to write to
        Set wsData = ActiveWorkbook.Sheets("Course Bookings")
         ' find first cell available for input
         'use End(xlUp) to avoid any empty rows in the table
        Set rNextCl = wsData.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
        With rNextCl
            .Value = Me.txtName.Value
            .Offset(0, 1) = Me.txtPhone.Value
            .Offset(0, 2) = Me.cboDepartment.Value
            .Offset(0, 3) = Me.cboCourse.Value
            If Me.optIntroduction = True Then
                .Offset(0, 4).Value = "Intro"
            ElseIf Me.optIntermediate = True Then
                .Offset(0, 4).Value = "Intermed"
            Else
                .Offset(0, 4).Value = "Adv"
            End If
            If Me.chkLunch = True Then
                .Offset(0, 5).Value = "Yes"
            Else
                .Offset(0, 5).Value = "No"
            End If
            If Me.chkVegetarian = True Then
                .Offset(0, 6).Value = "Yes"
            Else
                If Me.chkLunch = False Then
                    .Offset(0, 6).Value = ""
                Else
                    .Offset(0, 6).Value = "No"
                End If
            End If
        End With
         'reset form for input
        Call UserForm_Initialize
    End Sub
     
    Private Sub UserForm_Initialize()
         
        With Me
            .txtName.Value = ""
            .txtPhone.Value = ""
             'load comboboxes
            .cboDepartment.List = Array("Sales", "Marketing", "Administration", _
            "Design", "Advertising", "Dispatch", "Transportation")
            .cboCourse.List = Array("Access", "Excel", "PowerPoint", "Word", "FrontPage")
             'make sure  combos are displayinf empty
            .cboDepartment.ListIndex = -1
            .cboCourse.ListIndex = -1
            .optIntroduction = True
            .chkLunch = False
            .chkVegetarian = False
            .txtName.SetFocus
        End With
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486
       ActiveWorkbook.Sheets("Course Bookings").Activate
    The Above code wants to select a sheet called
    Course Bookings
    You don't have that sheet in your workbook
    change it to sheet1 or what ever name of the sheet you have

  4. #4
    Valued Forum Contributor
    Join Date
    01-02-2004
    Location
    malaysia
    Posts
    342
    Hi Dave & Roy,
    I have done it and it works.All informations I input were transfered to the worksheet. How do I create a "Report" to print them? or please give me some other example so that I can review and learn. Pls take a look at my file.Thanks a million
    Attached Files Attached Files

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486
    Hi, you could add another button the the UserForm
    and put a code in it something like this

    Private Sub CommandButton1_Click()
        Application.ActivePrinter = "\\Daves\PDF reDirect v2 on Ne10:"
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
            "\\Daves\PDF reDirect v2 on Ne10:", Collate:=True
    
    End Sub
    I just got the code from the macro recorder

  6. #6
    Valued Forum Contributor
    Join Date
    01-02-2004
    Location
    malaysia
    Posts
    342
    Hi Dave,
    I have copied your codes but it didnt work.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by seanyeap
    Hi Dave,
    I have copied your codes but it didnt work.
    That doesn't help at all! What error r you getting?

    Where have you copied the code to?

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486
    Quote Originally Posted by seanyeap
    Hi Dave,
    I have copied your codes but it didnt work.
    Hi Sean,
    You need to get your own code from the macro recorder

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1