Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Runtime ERROR 424
James Hopkins 
     
3 years ago
Hey Guys, I know must be overlooking something but I keep get this ERROR Message when running this CODE.

Public Sub PaymentTermsDueDateCal()

    If CboPaymentTerms.Column(0) = 1 Then
        InvoiceDueDate = Now()
    ElseIf CboPaymentTerms.Column(0) = 2 Then
        InvoiceDueDate = Date + 7
    ElseIf CboPaymentTerms.Column(0) = 3 Then
        InvoiceDueDate = Date + 10
    ElseIf CboPaymentTerms.Column(0) = 4 Then
        InvoiceDueDate = Date + 14
    ElseIf CboPaymentTerms.Column(0) = 5 Then
        InvoiceDueDate = Date + 20
    ElseIf CboPaymentTerms.Column(0) = 6 Then
        InvoiceDueDate = Date + 30
    ElseIf CboPaymentTerms.Column(0) = 7 Then
        InvoiceDueDate = Date + 45
    ElseIf CboPaymentTerms.Column(0) = 8 Then
        InvoiceDueDate = Date + 60
    ElseIf CboPaymentTerms.Column(0) = 9 Then
        InvoiceDueDate = Date + 90
    End If
    
End Sub
Kevin Robertson  @Reply  
          
3 years ago
Going to need more information:

    - How's your Form set up?
    - Where do you Call the above Sub Routine?
    - When you get the Error message and click Debug what line is highlighted?

-------------------------------------------------------------------------------------------

The code above works. Just a couple of notes:

    - You don't have to state .Column(0) - it is the default Column if omitted.
    - The code can be simplified with a Select Case statement (I think this makes it easier to read)

Public Sub PaymentTermsDueDateCal()

    Dim D As Date

    Select Case CboPaymentTerms
        Case 1: D = Date
        Case 2: D = Date + 7
        Case 3: D = Date + 10
        Case 4: D = Date + 14
        Case 5: D = Date + 20
        Case 6: D = Date + 30
        Case 7: D = Date + 45
        Case 8: D = Date + 60
        Case 9: D = Date + 90
    End Select
    
    InvoiceDueDate = D
    
End Sub


The variable isn't technically needed but I added it for readability.
James Hopkins OP  @Reply  
     
3 years ago
Thanks Kevin, I was thinking I was writing the VBA Code Wrong... Thank Again....
James Hopkins OP  @Reply  
     
3 years ago

James Hopkins OP  @Reply  
     
3 years ago

James Hopkins OP  @Reply  
     
3 years ago

James Hopkins OP  @Reply  
     
3 years ago
Here is what I had before.
Kevin Robertson  @Reply  
          
3 years ago
Check the name of your Combo Box. Make sure it is called cboPaymentTerms and spelled correctly..
Also consider using Option Explicit which will catch all Undefined Variables.
James Hopkins OP  @Reply  
     
3 years ago
Alrighty, will do. Thank Kevin...
James Hopkins OP  @Reply  
     
3 years ago

James Hopkins OP  @Reply  
     
3 years ago
In the "CboPaymemtTerms" combo box there's two columns: ID and Name.
Kevin Robertson  @Reply  
          
3 years ago
Go to the Properties of the Combo Box and check the Name.
James Hopkins OP  @Reply  
     
3 years ago
The combo box name is "CboPaymemtTerms" and the Row Source is "PaymentTermsID".
James Hopkins OP  @Reply  
     
3 years ago

James Hopkins OP  @Reply  
     
3 years ago

Kevin Robertson  @Reply  
          
3 years ago
Is this code in the Form Module? Or an External Module?

My screenshot below shows both.
Kevin Robertson  @Reply  
          
3 years ago

James Hopkins OP  @Reply  
     
3 years ago
Kevin you're awesome and thank you for your time....
Richard Rost  @Reply  
          
3 years ago
You don't need to specify .column(0). It's assumed.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

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/6/2026 3:52:26 PM. PLT: 1s