StLinkCriteria ??? (1 Viewer)

rubyred

Registered User.
Local time
Today, 07:11
Joined
May 9, 2002
Messages
23
When you use the wizards to do certain things, Microsoft uses the expression StLinkCriteria a lot. I can't understand what it is exactly doing. Here is an example:

Dim stDocName As String (I understand this)
Dim stLinkCriteria As String (??????)

stDocName = "NewCustomer" (Variable for form name - I think)
DoCmd.OpenForm stDocName,,,stLinkCriteria

Now here's where I don't understand what is happening. What is stLinkCriteria actually doing in this last line.

Thanks in advance for any explanations. I have been struggling with this for quite some time and decided to get an expert explanation.
 

David R

I know a few things...
Local time
Today, 01:11
Joined
Oct 23, 2001
Messages
2,633
stLinkCriteria is a variable for the 'WHERE' clause

In other words, if you asign a value to stLinkCriteria, it will try to only give you those form records that meet the criteria. An example would be:
Code:
Dim stDocName As String
Dim stLinkCriteria As String

  stDocName = "YourFormName"
  stLinkCriteria = "[LastName] = 'Jones'"
  
  DoCmd.OpenForm stDocName,,,stLinkCriteria
So your form would only open those records in [YourFormName] where the [LastName] field is 'Jones', exactly.

You can also use "[LastName] Like 'Jon*'", for example. The WHERE statement will look extremely similar to query criteria in Design View, and should look exactly like a query's WHERE clause in SQL view. (Open one of your queries in SQL view to see the correlation here).

From the OpenForm Method help file:
DoCmd.OpenForm formname[, view][, filtername][, wherecondition][, datamode][, windowmode][, openargs]
 

rubyred

Registered User.
Local time
Today, 07:11
Joined
May 9, 2002
Messages
23
Great David!!! Thanks so much for that explanation. I understand and feel much better now. By the way, I am using Access 97 here at work.

But, how does it work when stLinkCriteria information is not declared or defined as in the code I posted above?

The code I was looking at (exactly like I typed it above) was in a VBA "OnClick" Event and I can't see the connection with the stLinkCriteria. What am I not seeing?;)

So, was it necessary to have put this line of code in at all since nothing was declared for it? I'm surprised it didn't give an error message of some kind.

This is not my database, even though I am trying to modify it to a more user-friendly one, but I believe this code was generated from a command button wizard and not code that an individual personally wrote.

Thanks so very much for your help!
 

David R

I know a few things...
Local time
Today, 01:11
Joined
Oct 23, 2001
Messages
2,633
Fortunately, a blank string variable is not a problem there

What you're looking at is the result of a command button (I think) made by an Access Wizard. It asks the user what they want to do, what form to open (in this case), and if there should be any specific criteria. Since there were none, it leaves stLinkCriteria blank.

It's Dim(ensioned), but never takes a value. You could take out all the references to it in this case and not hurt the code (and even the commas before it in the OpenForm statement). It's just an example of automated wizards not working as intelligently as humans.
 

rubyred

Registered User.
Local time
Today, 07:11
Joined
May 9, 2002
Messages
23
Thanks so very, very much. You have certainly made my day!

I have been wondering about this for a long, long time. I have looked and looked in Access help for an explanation but have never been able to find anything!

I appreciate you taking the time to answer and you explained in such a way that anyone could understand. :)
 

Users who are viewing this thread

Top Bottom