ByRef Argument Type Mismatch?

A

ArielZusya

I've got a module which I call from all over my database. The module, stored
in basUniversals, is as follows:

Public Sub OpenFormAndClosePrevious(stDocName As String, Optional
stLinkCriteria As String, Optional stArgPasser As String)
On Error GoTo Err_MainMenu_Click

DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , stArgPasser

Exit_MainMenu_Click:
Exit Sub

Err_MainMenu_Click:
MsgBox Err.Description
Resume Exit_MainMenu_Click

End Sub


And then in my form I attemted to call it as follows:

Dim stConcat as String

stConcat = "RefNum = '" me.txtRefNum & "'"

Call OpenFormAndClosePrevious("frmNext",stConcat, stConcat)


On every other form and even on this form assigned to another button, this
method works without problem. For whatever reason, I'm suddenly getting the
error message "ByRef Argument Type Mismatch" with no meaningful help. What
suddenly changed? What am I doing wrong? Thinking Access might have just
been more forgiving elsewhere I tried compiling the project and the only
error I received was on this one instance of this call. I just don't get it.
Thanks for your help!
 
A

Allen Browne

OpenArgs can be Null, which would fail if assigned to a string.

To see if that's the problem, you could try:

Public Sub OpenFormAndClosePrevious(stDocName As String, _
Optional stLinkCriteria As String, _
Optional varArgPasser As Variant = Null)

Also, you may need to be aware that Access silently discards any record you
were in the process of entering, if there is any reason why it cannot be
saved (e.g. required field missing, validation rule not met, unique index
violated.) The fact that you get no error message leaves you with the false
impression that you actually entered a record, when in fact you did no such
thing. More info:
Losing data when you close a form
at:
http://allenbrowne.com/bug-01.html
 
A

ArielZusya

Thanks for the assist. I think this might have been the problem. All fixed
now. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top