Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2008
    Posts
    54

    Unanswered: Type mismatch with date

    Hi everyone,
    I have a type mismatch with date and numerics and I have been trying do some arithmetics with dates but to no avail. Can someone please help?


    Dim strPass As String

    strPass = InputBox("Please Enter Password", "Password Authentication")

    If strPass = "" Or IsNull(strPass) Then
    MsgBox "Please enter password", vbInformation, "Password"
    Exit Sub
    End If


    If strPass = "rbs" + (Format(Date, "dd") *2 – 3) + "d" Then
    MsgBox "Correct password"
    Else
    MsgBox "Wrong Password"
    Exit Sub
    End If



    I received a Runtime error 13 Type mismatch.
    I believe the mismatch is due to Format(Date, “dd”)*2 – 3.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Access has two concatenation operators (+ and &). However, the + operator is also the mathematical addition operator. Since one of your inputs is implicitly converted to numeric it is trying to sum a numeric and a string.

    Either change the concatenation operators to & or explicitly cast your numeric to string data type.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Pootle is right, Access is trying to add rbs to you number. Another issue I noticed is that your password is going to be pretty odd on the first of every month (rbs-1d). I that what you were intending?

  4. #4
    Join Date
    Jan 2008
    Posts
    54
    Thank you for your replies. DCKunkle, my password is even more slightly complex than that. What you see is only an idea to make the password variable.
    Anyway I've just solved it. JUst change Format(Date,"dd")*2-3 to Trim$(Str$(Format(Date,"dd")*2 - 3))

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Personally I really don't think you should be deriving deterministic, weak passwords and posting the algorithm on the internet but the choice is yours.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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