OpenArgs after converting from 97 to 2003

M

Mik

Hi,

I have a problen with the OpenArgs command after I have converted a database
from Access 97 to Access 2003.

I have a commandline like this

Open_frm "frmMenuMain", acEdit, "=frmMenuMain()"

.. It call the modul Open_frm
***
Function Open_frm(frmName As String, strReadEdit As String, strOpenArgs As
String)

DoCmd.OpenForm frmName, acNormal, , , strReadEdit, acNormal,
OpenArgs:=strOpenArgs

' I have tried with line without any help:
' DoCmd.OpenForm frmName, acNormal, , , strReadEdit, acNormal, strOpenArgs

End Function
***


.. And this is the modul in the form:
***
Private Sub Form_Open(Cancel As Integer)

Dim strForm_Open As String
strForm_Open = Forms!frmMenuMain.OpenArgs
Me.OnLoad = strForm_Open

End Sub
***
And its here the problem comes. Every time it says the "OpenArgs" is
null.....
I don't understand it because I have tried to put some msgbox to verify
and it seems not to be empty

I have tried with this function to verify that there is nothing wrong with
the form:
***
Private Sub Form_Open(Cancel As Integer)
Dim strForm_Open As String

If Not IsNull(Me.OpenArgs) Then
MsgBox "01"
strForm_Open = Forms!frmMenuMain.OpenArgs
Me.OnLoad = strForm_Open
Else
MsgBox "02"
strForm_Open = Me.Name
Me.OnLoad = "=" & strForm_Open & "()"
End If

MsgBox strForm_Open
'strForm_Open = "=frmMenuMain()"

End Sub
****

And that works.

Are the somebody who can help me a little I will say thanks in advance.

Mik
 
V

Van T. Dinh

Firstly, the call to the function Open_frm is inconsistent with its
declaration. You declared the second argument as a String and then passed a
number for this argument (acEdit is a Symbolic Constant with Numeric value).
However, Access probably does type-casting to String, passes it as a String
argument then convert it back to Numeric in the OpenForm statement.

Secondly, "=frmMenuMain()" looks pretty important to me but you are not
explaining what it is and what you expect Access / VB to do with this.

I am not sure why you even have to use the custom function Open_frm (it
really should be a Sub unless you want to use it with custom Menu commands)
rather than using the OpenForm directly.
 
G

Guest

Hi,

Thanks for your answer.

First of all I will say that thes functions has run in an Access 97 for many years without any problems.
However, Access probably does type-casting to String, passes it as a String
argument then convert it back to Numeric in the OpenForm statement.

As you write if I understand it correct it does not have any effect when
I have declared the second argument as a String.

I use the "Open_frm " function as a global function because many of the forms in the database
has the same procedure. That means that the OpenArgs call the modul "=frmMenuMain()"
which hold all the information concerning the text, color and behavior of all the fields
in the form. But why is it empty after I have convert the database..

Best regards

Mik




----- Van T. Dinh wrote: -----

Firstly, the call to the function Open_frm is inconsistent with its
declaration. You declared the second argument as a String and then passed a
number for this argument (acEdit is a Symbolic Constant with Numeric value).
However, Access probably does type-casting to String, passes it as a String
argument then convert it back to Numeric in the OpenForm statement.

Secondly, "=frmMenuMain()" looks pretty important to me but you are not
explaining what it is and what you expect Access / VB to do with this.

I am not sure why you even have to use the custom function Open_frm (it
really should be a Sub unless you want to use it with custom Menu commands)
rather than using the OpenForm directly.
 
V

Van T. Dinh

Not sure why but I haven't got A2K3 to test. I tested in A2K2 and it worked
fine. Here the code I test:

****
Public Function Open_frm(frmName As String, intReadEdit As Integer, _
strOpenArgs As String)
DoCmd.OpenForm frmName, acNormal, , , _
intReadEdit, acNormal, OpenArgs:=strOpenArgs
End Function

Public Function frmMenuMain()
frmMenuMain = "ABC"
End Function
****

and I called in the Immediate Window:

Call Open_frm("frmMenuMain", acFormEdit, "=frmMenuMain()")
?Forms!frmMenuMain.OpenArgs
ABC


--
HTH
Van T. Dinh
MVP (Access)



Mik said:
Hi,

Thanks for your answer.

First of all I will say that thes functions has run in an Access 97 for
many years without any problems.
 
M

Mik

Hi,

I tried but it seams that I did't have any luck.

I will try even harder it has to work, what has change between
A97 and A2000/2003????

Mik
 
V

Van T. Dinh

Sorry, can't help there as I haven't got A2003 set up.

Van T. Dinh
MVP (Access)
 

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

Similar Threads


Top