Consulting

Results 1 to 7 of 7

Thread: VBA form question

  1. #1
    VBAX Regular
    Joined
    Aug 2019
    Posts
    56
    Location

    VBA form question

    Hello all I have a general question which is
    Can you design a data entry form that places the data into a specific labeled worksheet (tab) in a shared work book .
    Currently I get paper request which has general info such as date , time , book however the discipline is specific. I have one work book with different tabs for the disciplines
    disciplins tabs .jpg

    Is there any way that a form may be created and based on the discipline selected , the info is saved into that specific tab.

    Just trying to minimize time and paper
    many thanks

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Multipage Control: One page per Discipline, "Discipline" as the Page Caption, each Page gets its own set of I/O controls

    "Regular" Form, with a Discipline selecting ListBox Control which sets the Module level Sheet Object Variable the data will be saved to.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Regular
    Joined
    Aug 2019
    Posts
    56
    Location
    Thanks for the reply . You wouldn't have an example would you ?

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    IF the fields are the same between disciplines, then I'd use a TabStrip control. IF NOT, then the logic can be adapted to a MultiPage control


    On CROWN & BRIDGE, the button runs the demo macro

    This is the userform code:


    Option Explicit
    
    
    Private Sub cbClose_Click()
        Me.Hide
        Unload Me
    End Sub
    
    
    Private Sub cbSave_Click()
        Dim wsToUpdate As Worksheet
        Dim rToUpdate As Range
        
        With Me
            Select Case .TabStrip1.Value  '   0 to 4
                Case 0
                    Set wsToUpdate = Worksheets("CROWN & BRIDGE")
                Case 1
                    Set wsToUpdate = Worksheets("ENDO")
                Case 2
                    Set wsToUpdate = Worksheets("GDP")
                Case 3
                    Set wsToUpdate = Worksheets("UNABLE TO FILL")
                Case 4
                    Set wsToUpdate = Worksheets("COMPLETE")
            End Select
        
            With wsToUpdate
                Set rToUpdate = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).EntireRow
            End With
            
            rToUpdate.Cells(1, 1).Value = .tbName.Value
            rToUpdate.Cells(1, 2).Value = .tbDate.Value
            rToUpdate.Cells(1, 3).Value = .tbTitle.Value
        
            'this clears the input
            .tbName.Value = vbNullString
            .tbDate.Value = vbNullString
            .tbTitle.Value = vbNullString
        End With
    
    
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    VBAX Regular
    Joined
    Aug 2019
    Posts
    56
    Location
    Ohh my goodness that looks perfect ! Cant thank you enough ( sincerely ) . let me digest the info as I am a newbie . one question is there any restrictions if the spread sheet is shared ?

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Quote Originally Posted by mml View Post
    Ohh my goodness that looks perfect ! Cant thank you enough ( sincerely ) . let me digest the info as I am a newbie . one question is there any restrictions if the spread sheet is shared ?

    Format is pretty crude and rough - I just wanted to show the idea
    If maintainability be comes a concern (e.g. Adding another worksheet, etc.) it can be made more robust, and hence more complex
    I tried to use a very straight forward technique, even if it's not the most elegant or bullet-proof

    Feel free to ask questions

    I'm not aware of any issues with sharing something like this, other than the usual issues with sharing a workbook
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  7. #7
    VBAX Regular
    Joined
    Aug 2019
    Posts
    56
    Location
    Even a basic form is a vast improvement to what I am using now ... appreciated . I have found a couple of other examples that I can adjust . Questions will come

Posting Permissions

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