Results 1 to 2 of 2

Need Help Calling a Form from a Sub

Threaded View

  1. #1
    Registered User
    Join Date
    01-17-2018
    Location
    Buffalo, New York
    MS-Off Ver
    2016
    Posts
    24

    Need Help Calling a Form from a Sub

    Hello!

    I am using my first form within a VBA project and could use assistance from the experts in this forum! Overall, the project is designed to automatically open a bunch of invoices and copy them over to the main file. In this file, I want to ask the user if an invoice is a specific number. If it is that number, then I want it to automatically code it something different than the excel formulas indicate. So more specifically...

    My goal is to call a form within a sub, enter data into the form, and then use the same data within the sheet and edit fields based on the data entered. The prompt opens and it allows me to enter data but then it never actually changes the information. I have isolated the code within the form and it worked as stand alone code - however, when I try to call it from the form - it simply continues without actually making the edits. There is no error message or anything like that, it just doesn't do what I want it to do. I think this must be a simple error but I could really use some help here - I am banging my head against the wall on this one...

    In order to call form I created from a sub can I simply put:
    invoiceOptionsMsgBox.Show
    Here is the code within the form, perhaps this is where the problem is located.:
    Private Sub answerNo_Click()
    
    Unload invoiceOptionsMsgBox
    '' "When Excel displays the dialog box, the macro halts until the user closes the dialog box. Then VBA executes any remaining statements in the procedure. Most of the time, you won’t have any more code in the procedure. As you later see, you can put your macro code in the Code window for the UserForm."
            '' Above text located @ http://what-when-how.com/excel-vba/excel-vba-custom-dialog-box-basics/
            '' Therefore, I think you can just keep calling of the msgBox within the macro code and it will further execute the larger macro once the answer is no.
    ''call the sub (which you will have to split into a new Sub? Not sure if that is true...) that finishes the process. Figure out how to call a seperate macro (or sub) to execute from within a different sub
    
    End Sub
    
    Private Sub answerYesSO_Click()
    
    Dim SOinvoiceNumberInput As Variant   ''in the future make it so it's an integer and if the person doesn't enter an integer then prompt them to fix their entry.
    'prompt box to receive PFD data info
    SOinvoiceNumberInput = InputBox("Please Enter the Invoice PFD Invoice Number:", "PFD Invoice Entry")
    'the variable invoiceNumberInput will now contain the invoice number we need to go look for in column H
    
    End Sub
    
    Private Sub answerYesPFD_Click()
    
    Dim a As String, c As Range
    Application.ScreenUpdating = False
    a = CStr(Application.InputBox("Enter a value to search for.", "Enter value", Type:=2))
        For Each c In Range("B4:B" & Cells(Rows.Count, 2).End(xlUp).Row)
            If c.Value = a Then c.Offset(, 6).Value = "500-00-01"
        Next c
    Application.ScreenUpdating = True
    
    End Sub
    
    Private Sub invoiceTypeText_Click()
    
    End Sub
    
    Private Sub UserForm_Click()
    
    End Sub
    It might be easier to analyze the problems by viewing the workbook and code directly so I have attached the sanitized Invoice Creator workbook as well as four example invoice work books. When the prompt comes up I want to select PFD and enter invoice number "36230352" and "36230354", then select SO and enter invoice number "36230355" and then, finally, select no.

    Any help on this would be greatly appreciated!!
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Calling a User Form from VBA
    By John Vieren in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-18-2018, 05:45 AM
  2. Calling Excel's built in form
    By imogul in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-26-2015, 09:10 PM
  3. Calling data entry form from VBA
    By sardalashvili in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2013, 05:00 AM
  4. Calling a user form initialize sub when entering the form to populate combobox...
    By regupnorth in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-02-2012, 07:24 AM
  5. [SOLVED] Calling and prefilling a form from another form
    By jlt199 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-05-2012, 04:18 PM
  6. calling function form within sub
    By Dirk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-16-2006, 09:30 AM
  7. Calling the Print Form
    By Derek from Belgium in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-23-2005, 10:06 AM

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