Results 1 to 8 of 8
  1. #1
    mdex is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    11

    Date - Textbox type mismatch 13

    I have a bit of code which on form load look up a textbox value, compares it to the current date and if more than 25 days ago produces an input box.



    This input box has todays date as the default value and when the user clicks ok sets the text box as this date.

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

    If (Date - txtswiddate) >= 25 Then

    Dim msg2, Title2

    msg2 = "BLAH BLAH."
    Title2 = "TITLE BLAH"
    Default2 = (Date)

    response2 = InputBox(msg2, Title2, Default2)

    txtbox.Value = response2

    End If

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

    The textbox format is general date.

    If I type the date into the text box as 25/12/2011 and then reload the form the code runs correctly and changes the text box to 19/01/2012.

    If the form is reloaded again I get a type mismatch 13 error!?

    I'm not an access guru by any means and presume it has something to do with the textbox not being the correct format?? but can't figure out how to fix it.

    Any help is gratefully appreciated!

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    On loading the form there is no data available on the form, don't do that check at that time (the two dates are the same anyway, both today's date). Do the check on the AfterUpdate event of the textbox.

  3. #3
    mdex is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    11
    Quote Originally Posted by aytee111 View Post
    On loading the form there is no data available on the form, don't do that check at that time (the two dates are the same anyway, both today's date). Do the check on the AfterUpdate event of the textbox.
    Ah, duh! Of course. Textboxes don't keep their data.

    Not sure how doing it on the textbox AfterUpdate will work.

    I wanted to hide the textbox and not have it updateable by any users.

    It may help to explain why I'm doing this. We have a system which we don't loginto very often and password expire after 30 days. If you don't use it for another X amount of days after that your account is disabled.

    I want a popup on a 25-28 day interval to remind them they need to login.

    I'm self teaching myself access/vb and doing this as sort of a self project at work. I haven't had any dealings with it since Uni over 10 years ago. Sorry if I miss something obvious.

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Where and when do you want the pop-up to appear? Will they be in this Access database or do you want it to be independent of/external to this database?

  5. #5
    mdex is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    11
    Quote Originally Posted by aytee111 View Post
    Where and when do you want the pop-up to appear? Will they be in this Access database or do you want it to be independent of/external to this database?
    I have a frontend with a switchboard and want the popup to appear from that form when it is loaded preferably.

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I'm not sure that I have this straight - is the switchboard always open? There needs to be an event that triggers your date check. You say "when it is loaded" - when what is loaded?

    The date check can be done when that event occurs. The date-last-logged-in for each user will be kept on a table. A query will run (or a piece of vba code) which will then that date against today's date and display the form to the user if it is more than a certain number of days.

    Does this make sense?

    PS Don't apologise for asking questions - there is no such thing as a stupid question! We're here to help.

  7. #7
    mdex is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    11
    My mind works in strange ways especially not knowing access too well yet.

    The switchboard is the 'main menu' which auto loads when the front-end is opened. My original idea was reliant on people reopening the front end every day which wouldn't always happen.

    I didn't want to note login dates for each individual user. This code will be used on the front end which is used by a team of only 4 people.

    In essence I need a popup to occur every 25 days as a reminder to check user last login dates.

  8. #8
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I don't know how you are going to accomplish this.

    The event that triggers the form to pop up - I am still not sure what it is. Is it outside of Access or only when they open the database? What if they don't open the database for 30 days? I presume you keep the password-expiry-date on a table?

    If this is happening in Access when they open the database, it is easy enough to put a piece of VBA code in the startup to check whether their password has expired or is about to expire. It is probably also possible to do with a query and a macro if you feel more comfortable with that.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA DLookup - Type Mismatch
    By hannuk in forum Access
    Replies: 2
    Last Post: 01-03-2012, 06:33 AM
  2. Type Mismatch....WHY?!!?
    By jgelpi16 in forum Queries
    Replies: 9
    Last Post: 03-07-2011, 09:18 AM
  3. Type Mismatch
    By Alex Motilal in forum Programming
    Replies: 10
    Last Post: 02-13-2011, 05:42 AM
  4. Type mismatch
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 08-07-2010, 06:54 AM
  5. Type Mismatch - HELP!
    By jgelpi in forum Programming
    Replies: 3
    Last Post: 07-17-2009, 03:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums