Input Box Date Validation

0 votes

I have an update form for my project. A message box appears after the user clicks an update button requesting them to confirm the delivery date. A Yes/No message box is displayed here. When the user selects No, an input box where they can type the correct date displays.

The issue I'm encountering is with the data validation that happens after the user-inputted date. I'm trying to make sure the user entered a real date and not just a bunch of alphabetic symbols. This function starts at "Line1" in the code. The Otherwise sentence below "Line1" is where the issue is. If I type a date that is properly typed, the code jumps to the Msgbox before bringing me back to "Line1." I don't get the Message box asking me to change the date if I enter a string of alpha characters; instead, I get a Runtime Error 13 Type Mismatch.

Range("A" & Rows.Count).End(xlUp).Offset(1).Select
iRow = ActiveCell.Row
lastRow = ws3.Cells(ws3.Rows.Count, 1).End(xlUp).Row

For i = 3 To lastRow 'Isolate the Record, Get data, and move
    wo = Cells(i, 1).Value
    pn = Cells(i, 2).Value
    sn = Cells(i, 3).Value
    n = Cells(i, 6).Value
    If Me.txt_WN.Value = wo Then
        If Me.txt_pn.Value = pn Then
            If Me.txt_sn.Value = sn Then
                If n = "Yes" Then
                    dd = MsgBox("Is this the correct delivery date? " & Curr, vbYesNo)
                        If dd = vbYes Then
                            dd = Curr
                        Else
Line1: 'Problem exists here
                            If IsDate(dd = InputBox("Enter the Correct Delivery Date", "Deliver to Stores Date")) Then
                                dd = Format(dd, "mm/dd/yyyy")
                            Else
                                MsgBox "The date is formatted incorrectly, please recheck entry"
                                GoTo Line1
                            End If
                                'If IsDate(dd) Then
                                '        dd = Format(dd, "mm/dd/yyyy")
                                'Else
                                '    MsgBox "The date is formatted incorrectly, please correct"
                                '    GoTo Line1
                                'End If
                        End If
                    GoTo Update
                Else
                    MsgBox "This Wheel S/N was not marked as Due for NDT"
                    Exit Sub
                End If
            End If
        End If
    End If
Next i

A second if statement that has been commented out can be seen below the first If Statement following "Line1." In such case, pressing the No button on the message box would input "1/7/1900," essentially avoiding the need to enter the code for validation (I think).

I have no idea what is happening. Similar validation code that I used in other subroutines worked perfectly. Any ideas as to where I might be going wrong would be greatly appreciated.

Feb 27, 2023 in Others by Kithuzzz
• 38,010 points
339 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Others

0 votes
1 answer

Is there any way to change input type="date" format?

To answer your question, it is impossible ...READ MORE

answered Feb 18, 2022 in Others by Aditya
• 7,680 points
14,688 views
0 votes
1 answer
0 votes
1 answer

What is black box testing?

Back box testing is where the tester ...READ MORE

answered Feb 18, 2019 in Others by Adi
992 views
0 votes
2 answers

What is white box testing and how is it different from black box testing?

Black Box Testing is a software testing method in ...READ MORE

answered Feb 20, 2019 in Others by preetiagarwal
• 170 points
2,055 views
0 votes
0 answers

Date time convert in Replace activity in word document scope

we have input in excel  New date/Header 31/12/2020 31/12/2019 We  want ...READ MORE

Jun 22, 2020 in Others by Sapna
• 120 points

recategorized Jun 22, 2020 by Gitika 382 views
+1 vote
0 answers

I am not able to see the chat box on webinar-session. i can see only ask question pane

Today (8/aug/2020) I have joined one webinar, ...READ MORE

Aug 9, 2020 in Others by Ravibharathi
• 130 points
1,215 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,006 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,371 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
679 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,670 points
889 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP