I do understand it when it's a literal string, but like you said - when its refering to an object within a string - is where i dont get it.
Thanks for your assistance with this. I really appreciate it! This search form is making go nuts. I have it so that they can search by either Group Name, Group Number, or Cruise Line AND sail date. The only problem with Cruise Line and Sail date is: What if there are multiple Groups on the same cruise line and on the same date? I'm not sure how to handle this....right now its just opening the form with the first qualifying group showing.
Neekos,
Ok, understand that in the case where an object is supplying a value at runtime, that object/variable has to be separated out of the string in order for Access to know that there is a value to be returned to the string. Once the value is returned, Access needs to know how to treat it....Is it a numeric value or part of a text string. If the object or variable that is supplying the return value is of the data type that returns a text value to the string, there are an extra set of quotes to designate the return value as text.
example>>>>>>"[GroupNumber] = '" & Me![GroupNumber] & "'"
and if the return is numeric data type, no extra quotes are needed:
for example if GroupNumber were numeric:
>>>>>>"[GroupNumber] = " & Me![GroupNumber]
__________________________________________________ ______________
In reference to your other question, there are several ways to go about it. Off the top of my head (I haven't had the time to test this) , i think this would be my preference:
1. go to your table and create a composite index using the index button in table design view. the index would be on Cruise Line/sail date/groupnumber. This index would be used internally by Access to speed up the search.
2. on your main form, I assume you already capture the Cruise Line/sail date/group number in respective text boxes, so I would place a textbox (e.g. txtCruiseLineIdx) on the form, set its visible property to no, and define its control source as the concatenated value of the 3 controls as shown below. By making the textbox hidden, the search index will be hidden from users.
txtCruiseLineIdx = Me!txtCruiseLineName & Me!txtSailDate & Me!txtGroupNumber
Then do your search Like before
stLinkCriteria = "[txtCruiseLineIdx] = '" & Me!txtCruiseLineIdx & "'"
DoCmd.OpenForm stDocName,,,stLinkCriteria
If for some reason that does not work, try the search this way.
' I believe focus can be set on an invisible textbox as long as control is enabled and not locked.:
Me.txtCruiseLineIdx.SetFocus
DoCmd.FindRecord Me!txtCruiseLineIdx
Me!GroupNumber.SetFocus
Let me know how it goes.