Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with openargs

Status
Not open for further replies.

tkcrosbie

Programmer
Aug 17, 2001
12
US
when I use the openargs paramater of the docmd.openform method the first time I call the new form the openargs value is null! After it is called once then the value is passed as required.

Is anyone familiar with this situation???

I am using officexp and windows xp
 
Could you post a couple lines of your call? Have you tried trapping the code in the form_open event? Is there any processing done by the form of the arguments being passed?

----------------------
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
 
form1 code
stDocName = "ItemApproval"
stLinkCriteria = Me.req_idx
DoCmd.OpenForm stDocName, , , , , , stLinkCriteria

form2 code
Sub Form_Open(Cancel As Integer)
test = Forms!ItemApproval.OpenArgs

debug shows the value in stlinkcriteria in form1
the value is null in form2

this is evaluated by steping thru the code using the debug f8 command
 
I doesn't appear you are sending the OpenArgs value.

DoCmd.OpenForm FormName, View, Filtername, WhereCondition, DataMode, WindowMode, OpenArgs

DoCmd.OpenForm stDocName, , , , , , stLinkCriteria

Normally a stLinkCriteria would be the WhereConditin but it looks like it is in the OpenArgs position. What do you do with this value when the ItemApproval form opens?

stDocName, , , , , , stLinkCriteria
DoCmd.OpenForm FormName:=stDocName, OpenArgs:="OpenArgs Value"

----------------------
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
 
stlinkcriteria is just a variable name with my transfer value in it
 
I quit trying to use openargs and settled on accessing the field in the calling form. Here is the code

holdafe = Forms!AFE.AFE_Number

holdafe is a field(hidden) on my new form
afe_number is a field on the calling form

after all a form is a class (sort of)
 
I created two forms and used your code. No problems. Here is what I have:

Form Name: Form1 (with 1 text box: req_idx and 1 button: cmdOpenItemApproval)

Private Sub cmdOpenItemApproval_Click()
On Error GoTo Err_cmdOpenItemApproval_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ItemApproval"
stLinkCriteria = Me.req_idx
DoCmd.OpenForm stDocName, , , , , , stLinkCriteria

Exit_cmdOpenItemApproval_Click:
Exit Sub

Err_cmdOpenItemApproval_Click:
MsgBox Err.Description
Resume Exit_cmdOpenItemApproval_Click

End Sub

Form Name: ItemApproval (with 1 text box: Test)

Private Sub Form_Open(Cancel As Integer)
Test = Forms!ItemApproval.OpenArgs
End Sub


Might just want to check that the codes are in the correct events. I have started using OpenArgs alot lately and have not had any issues. I am using Access97, so if you hare using a newer version there may be a bug.

Bill
 
tkcrosbie

A form is more than a class (sort of); it is a class. You can set and get properties on the code-behind-the-form exactly as you can in a class. You also can not execute a public function from the immediate window unless you provide the form name (class name).

----------------------
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
 
I guess we can conclude that there is a problem in either office xp or winxp. The first call which uses open args always contains null on my system. I find it very interesting that access 97 has no problems at all with the same code.

Thanks for the definitive awnser on the class. I am much more of a c++ type and was hedging my bets on the class definition.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top