Results 1 to 6 of 6
  1. #1
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659

    Referencing an Accde and getting ByRef Mismatch

    I have an ACCDB that has a custom Type that is used in a function call.



    When the Project is used as a reference library in ACCDB Form, the calls work. great. I get no errors.

    When I converted the ACCDB to ACCDE and then use the same calls, I get an Compiler Byref Mismatch, even though the signature is a complete match of how it worked previously.

    Im guessing this stems from the function call not having its parameters established as byval or byref, so they are set byref by default.

    The MSDN help on this issue says Im passing a type that can't be coerced/cast into the type that is used. but they are the same type.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Not sure I follow perfectly, but ByRef is the default. So, yes, I would expect an error that mentions ByRef even when you did not explicitly define ByRef.

    Aside from that, not sure why there would be an issue with accde vs. accdb. If I were to isolate an accde vs accdb issue (without considering a custom function or a specific error) I would ask if the accde was produced by a later version of Access than the client version running the accde. For instance, was the accde created using 2013 and then the problem occurred when using 2010 RT.

    Specific to the Mismatch error, I would see if the declaration in the function's parameters matches the data type passed via the argument. Perhaps there was an implicit declaration of a Variant type string and not an explicit type string in the argument.

  3. #3
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Thank you, I will review more.

  4. #4
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Looks like I had copied the Custom type into a local module and it was using that type instead of the one in the reference lib. Even though it was just copied and pasted into the local. When I removed the local declaration for the type, the error went away.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    That sounds pretty cool. What are you storing your Types in, Classes? All of these Classes reside in an Access file that acts as a Class Library? This Access file is then Referenced via tools>References?

  6. #6
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Yes, yes yes and Yes =). Its pretty great.

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

Similar Threads

  1. Another ByRef type mismatch
    By Levonas in forum Programming
    Replies: 3
    Last Post: 03-05-2015, 03:06 PM
  2. Compile Error: ByRef argument type mismatch
    By gaker10 in forum Programming
    Replies: 3
    Last Post: 11-17-2014, 10:33 AM
  3. VBA ByVal vs ByRef Passing Arguments
    By ylatodd in forum Programming
    Replies: 5
    Last Post: 10-22-2013, 02:49 PM
  4. byref argument type mismatch error
    By karuppasamy in forum Access
    Replies: 1
    Last Post: 06-22-2011, 09:37 AM
  5. ByRef error...never seen it before
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 02-16-2011, 03:09 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