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!

Forms!a_form.OpenArgs - does not recognise

Status
Not open for further replies.

biot023

Programmer
Nov 8, 2001
403
GB
When I try to pass OpenArgs to a form, I just get an error message telling me Variable Not Defined.
I must admit, I'm having a hard seeing the use of an OpenArgs property that can't be recognised, so I assume I'm doing something foolish.

I pass the OpenArgs with the following code:
argstring = "SELECT * FROM Index WHERE Index.CC_Page=" & userID & " AND Index.CC_Reject=7;"
DoCmd.OpenForm "the_indexer", acNormal, , , , , argstring

And then try to utilise it with the following:
Private Sub Form_Open(Cancel As Integer)
If Not IsNull(Forms!the_indexer.OpenArgs) Then
Me.RecordSource = Forms!the_indexer.OpenArgs
End If
End Sub


Anybody any ideas why this won't work? I think I'm going mad...

Any help very VERY appreciated. If it don't make you laugh, it ain't true.
 
Try this:
Code:
Private Sub Form_Open(Cancel As Integer)
Me!RecordSource = IIF(Me!OpenArgs, Me!OpenArgs, "{some other source}" )
End Sub

You'll need to plug in the "some other source" here...and you may need to do a REQUERY there too...



Jim Hare
"Remember, you're unique - just like everyone else"
 
The error is when you assign argstring. If userID = "Joe" then your SQL String reads
SELECT * FROM Index WHERE Index.CC_Page= Joe AND Index.CC_Reject=7;

So the form tries to evaluate Joe as a variable, put some text delimeters around userID and you should be good to go.

JHall
 
You shouldn't have a problem with the SQL string as long as ID is a number. Otherwise you'll need to wrap the variable inside CHR(34) or CHR(39).

I think the problem is here:

Private Sub Form_Open(Cancel As Integer)
If Not IsNull(Forms!the_indexer.OpenArgs) Then
Me.RecordSource = Forms!the_indexer.OpenArgs
End If
End Sub

Open args are funky in that they aren't persistent and they can't be referenced absolutely in the forms!frmSuch.Property manner. The property exists in the open event and it's referenced the same from parent and child form. So you'd have:

Private Sub Form_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
Me.RecordSource = Me.OpenArgs
End If
End Sub
 
The whole thing is freaked out!
I can't place On Open events - even empty ones - on any forms!
Could this have been the problem?
Does anybody know what to do about this?
I've tried repairing the database, which says all is fine, and endlessly Compacting it, but nothing solves the problem.
Mein Gott!

Douglas If it don't make you laugh, it ain't true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top