Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Custom MsgBox 10    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Message Box In Message Box
James Hopkins 
     
2 years ago
Hey Richard and the Crew, I watched the "Custom MsgBox Series", they were awesome to watch and very informational. I been using the Codes in the Custom Msg Box to Generate the Messages for the Notifications in the Database. I am wondering if there's a way to create an Custom Message Box within another Custom Message Box, if a 'Invoice' is already created for an 'Estimate' already?
Richard Rost  @Reply  
          
2 years ago
Not quite sure I follow. Wouldn't it just be calling the MsgBox twice in a row?
James Hopkins OP  @Reply  
     
2 years ago
Here's the Code I have so far:

DetailsPrivate Sub BtnMarkEstimateCompletedInvoice_Click()

    Dim N As Long
    
    N = CustomMsgBox("This Estimate has not been Invoiced yet. Do you want to generate Invoice from this Estimate? Do you won't to Proceed?", "Allow this Estimate to be 'Mark Estimate Complete & Invoice'", "Yes", "No", "Cancel", 2, 3, _
        "FCFC1C", "0E309A", "Times New Roman", 12, 2800, 7000, IconExclamation, 3)
            
    If N = 1 Then
        If Not IsNull(DLookup("EstimateID", "InvoiceT", "EstimateID=" & EstimateID)) Then
            
            Dim N2 As Long
    
            N2 = CustomMsgBox("Invoice for this Estimate was Find. You cannot create an Invoice for this Estimate, Again!", "Invoice found for this Estimate", "Ok", "", "Cancel", 1, 3, _
                "FCFC1C", "0E309A", "Times New Roman", 12, 2800, 7000, IconExclamation, 3)
                    
            If N2 = 1 Then
                Exit Sub
            ElseIf N2 = 2 Then
                Exit Sub
            Else
                Exit Sub
            End If
            
        ElseIf IsNull(DLookup("EstimateID", "InvoiceT", "EstimateID=" & EstimateID)) Then

Dim N3 As Long
    
            N3 = CustomMsgBox("This Estimate has not been Invoiced yet. You cannot Mark this Estimate 'Completed & Invoiced'? Do you won't to Proceed?", "Allow the Creation of Invoice for Estimate'", "Ok", "", "Cancel", 1, 3, _
                "FCFC1C", "0E309A", "Times New Roman", 12, 2800, 7000, IconExclamation, 3)
                    
            If N3 = 1 Then
                DoCmd.RunSQL "UPDATE EstimateT SET EstimateStatusID  = '354' WHERE EstimateID=" & EstimateID
            Forms! EstimateDashboardF! EstimateDetailInfoSubF.Form.Requery
            ElseIf N3 = 2 Then
                Exit Sub
            Else
                Exit Sub
            End If
        End If
    ElseIf N = 2 Then
        Exit Sub
    Else
        Exit Sub
    End If

End Sub
Richard Rost  @Reply  
          
2 years ago
Yeah, so you're just calling multiple MsgBoxes one after the other. I don't know what you mean by one WITHIN another.
Kevin Robertson  @Reply  
           
2 years ago
I don't understand this code:

If N2 = 1 Then
    Exit Sub
ElseIf N2 = 2 Then
    Exit Sub
Else
    Exit Sub
End If


Aren't you are exiting the sub whatever option is selected?
James Hopkins OP  @Reply  
     
2 years ago
Oh okay Richard, yeah. That is what I am trying to do. I can just call the  Custom Msg Box and Dim N As Long for Msg 1, Dim N2 As Long for Msg 2, and Dim N3 As Long for Msg 3 if needed.
Richard Rost  @Reply  
          
2 years ago
Yeah, there really isn't a need for a box WITHIN another box. Not that I can think of anyhow.
James Hopkins OP  @Reply  
     
2 years ago
Thanks Richard, I think I got it now.
James Hopkins OP  @Reply  
     
2 years ago
Sorry Guys, I have ran into a problem when trying to use two option if 'Invoice is Created or Not':

DetailsPrivate Sub BtnMarkEstimateCompletedInvoice_Click()
    
    If DLookup("EstimateID", "InvoiceT", "EstimateID=" & EstimateID) = False Then

        Dim N As Long
        
        N = CustomMsgBox("This Estimate has not been Invoiced yet. Do you want to generate Invoice from this Estimate?", "Allow this Estimate to be 'Mark Service Workorder Complete & Invoice'", "Yes", "No", "Cancel", 2, 3, _
            "FCFC1C", "0E309A", "Times New Roman", 12, 2800, 7000, IconExclamation, 3)
                
        If N = 1 Then

            Dim db As DAO.Database
            Dim rsEstimate As DAO.Recordset
            Dim rsEstimateDetail As DAO.Recordset
            Dim rsInvoice As DAO.Recordset
            Dim rsInvoiceProductDetail As DAO.Recordset
            Dim rsInvoiceServiceDetail As DAO.Recordset
            Dim strSQL As String
        
            ' Open the database
            Set db = CurrentDb
        
            ' Open the Estimate recordset
            Set rsEstimate = db.OpenRecordset("SELECT * FROM EstimateT WHERE EstimateID=" & EstimateID)
        
            ' Check if there are any records in the Estimate table
            If Not rsEstimate.EOF Then
                ' Open the Invoice form in add mode
                DoCmd.OpenForm "InvoiceF", acNormal, , , acFormAdd, acWindowNormal
        
                ' Get the Invoice recordset
                Set rsInvoice = Forms("InvoiceF").RecordsetClone
        
                ' Copy the Estimate record data to the Invoice form
                rsInvoice.AddNew
                rsInvoice!InvoiceTitle = rsEstimate!DLookup("FieldHelperData", "FieldHelperT", "FieldHelperID=" & [EstimateTypeID])
                rsInvoice!InvoiceDate = Date
                rsInvoice!ClientID = rsEstimate!ClientID
                rsInvoice!PropertyID = rsEstimate!PropertyID
                rsInvoice!ServiceWorkorderID = rsEstimate!ServiceWorkorderID
                rsInvoice!PaymentTermsID = rsEstimate!PaymentTermsID
                rsInvoice!InternalNotes = rsEstimate!Notes
        
                ' Copy other relevant fields here
                rsInvoice.Update
        
                ' Open the Estimate Detail recordset
                Set rsEstimateDetail = db.OpenRecordset("SELECT * FROM EstimateDetailT WHERE EstimateID = " & rsEstimate! EstimateID)
        
                ' Get the Invoice Product Detail recordset
                Set rsInvoiceProductDetail = Forms("InvoiceF").Controls("InvoiceProductDetailF").Form.RecordsetClone
        
                ' Copy the Estimate Detail data to the Invoice Product Detail form
                rsEstimateDetail.MoveFirst
                Do Until rsEstimateDetail.EOF
                    rsInvoiceProductDetail.AddNew
                    rsInvoiceProductDetail!ProductID = rsEstimateDetail!ProductID
                    rsInvoiceProductDetail!ProductName = rsEstimateDetail!ProductName
                    rsInvoiceProductDetail!Quantity = rsEstimateDetail!Quantity
                    rsInvoiceProductDetail!UnitPrice = rsEstimateDetail!UnitPrice
                    rsInvoiceProductDetail!ProductDiscountPercentage = rsEstimateDetail!ProductDiscountPercentage
                    rsInvoiceProductDetail!ProductSalesTaxPercentage = rsEstimate!ProductSalesTaxPercentage
        
                    ' Copy other relevant Product Fields here
                    rsInvoiceProductDetail.Update
                    rsEstimateDetail.MoveNext
                Loop
                
                ' Get the Invoice Service Detail recordset
                Set rsInvoiceServiceDetail = Forms("InvoiceF").Controls("InvoiceServiceDetailF").Form.RecordsetClone
        
                ' Copy the Estimate Detail data to the Invoice Detail form
                rsEstimateDetail.MoveFirst
                Do Until rsEstimateDetail.EOF
                    rsInvoiceServiceDetail.AddNew
                    rsInvoiceServiceDetail!ServiceID = rsEstimateDetail!ServiceID
                    rsInvoiceServiceDetail!ServiceName = rsEstimateDetail!ServiceName
                    rsInvoiceServiceDetail!Hours = rsEstimateDetail!Hours
                    rsInvoiceServiceDetail!Rate = rsEstimateDetail!Rate
                    rsInvoiceServiceDetail!BudgetedHours = rsEstimateDetail!BudgetedHours
                    rsInvoiceServiceDetail!ServiceDiscountPercentage = rsEstimateDetail!ServiceDiscountPercentage
                    rsInvoiceServiceDetail!ServiceSalesTaxPercentage = rsEstimateDetail!ServiceSalesTaxPercentage
        
                    ' Copy other relevant Service Fields here
                    rsInvoiceServiceDetail.Update
                    rsEstimateDetail.MoveNext
                Loop
        
                ' Close recordsets
                rsEstimateDetail.Close
                rsInvoiceProductDetail.Close
                rsInvoiceServiceDetail.Close
            Else
                MsgBox "No Estimate found.", vbInformation
            End If
        
            ' Close recordsets
            rsEstimate.Close
            
            Set rsEstimate = Nothing
            Set rsEstimateDetail = Nothing
            Set rsInvoice = Nothing
            Set rsInvoiceProductDetail = Nothing
            Set rsInvoiceServiceDetail = Nothing
            Set db = Nothing
        
            DoCmd.Close acForm, "EstimateDetailInfoSubF", acSaveYes
            
            End If
      
        ElseIf N = 2 Then
            Exit Sub
        Else
            Exit Sub
        End If
        
    Else
        If DLookup("EstimateID", "InvoiceT", "EstimateID=" & EstimateID) = True Then
        
        Dim N2 As Long
        
        N2 = CustomMsgBox("Invoice for this Estimate was Find. You cannot create an Invoice for this Estimate, Again!", "Invoice found for this Estimate", "Ok", "", "Cancel", 1, 3, _
                "FCFC1C", "0E309A", "Times New Roman", 12, 2800, 7000, IconExclamation, 3)
                        
        If N2 = 1 Then
            Exit Sub
        Else
            Exit Sub
        End If
        
     End If
    
End Sub
James Hopkins OP  @Reply  
     
2 years ago
I keep getting an ERROR Message: "Compile error: Else without If". I could figure out where to Error coming from.
Sami Shamma  @Reply  
             
2 years ago
It's telling you what the error is!
I would print this out on a paper and match each IF statement with its ELSE and END IF.
Richard Rost  @Reply  
          
2 years ago
This is why proper indenting is so important.
James Hopkins OP  @Reply  
     
2 years ago
Thanks Sami, I did you recommended and found out where I messed up at. I had to make a few changes. Also, thanks Rishard, I see what you meant about 'Proper Indenting so Important'.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Custom MsgBox 10.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/2/2026 12:02:14 AM. PLT: 1s