Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2011
    Posts
    2

    Unanswered: Run-Time error 13: Type Mismatch on checking user name

    Hi all.

    I get the above error when attempting to check the username during a Form_Open event in Access 2003 (the form is part of the start-up of the database, specified in a macro named 'autoexec'). The code is below with the failing line highlighted in red:

    Code:
    Dim FirstCheck As String
    Dim varStart As Variant
    Dim UserInDB As String
            
        UserInDB = Environ("USERNAME")
        FirstCheck = Dir("\\Quite Long Path Name! \chkfile.ozx")
        If FirstCheck <> "chkfile.ozx" Then
                If UserInDB = "John.Smith" Or "Fred.Bloggs" Then
                Exit Sub
                End If
    I realise that I've probably just been dumb, but of course can't see where!
    Thanks in advance for any help!

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    thats not the way you write compund if statements in VBA (or any toher language that I can remember for that matter
    If UserInDB = "John.Smith" Or "Fred.Bloggs" Then
    should read
    If UserInDB = "John.Smith" Or UserInDB = "Fred.Bloggs" Then
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Sep 2011
    Posts
    2
    Quote Originally Posted by healdem View Post
    thats not the way you write compund if statements in VBA (or any toher language that I can remember for that matter

    should read
    Thanks! Can't believe I did that!! Would be good to pay attention sometimes wouldn't it!

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    well if you've tried that, have you thought of using the network logon rather than the current user. if so have a look at the network API calls int he codebank or do a google for Dev Ashish API
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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