[AccessD] Re: Concatenated stLinkCritria produces Type mismatch

Robert L. Stewart rl_stewart at highstream.net
Wed Jan 28 10:56:47 CST 2004


Personally, I do not use the criteria on the form.
I will base the form on a query.  I just change
the SQL for the query before opening the form.
I use the same technique for reports.  After
doing it a couple of times, I think you will
find it simple.

If you need a code sample for the process, I
can send it out to the list.

Robert

At 08:44 PM 1/27/2004 -0600, you wrote:
>Date: Wed, 28 Jan 2004 11:03:57 +1000
>From: "Stuart McLachlan" <stuart at lexacorp.com.pg>
>Subject: RE: [AccessD] Concatenated stLinkCritria produces Type
>         mismatcher      ror.
>To: Access Developers discussion and problem solving
>         <accessd at databaseadvisors.com>
>Message-ID: <4017971D.17970.2E2ECEE6 at localhost>
>Content-Type: text/plain; charset=US-ASCII
>
>If it's only once or twice in an app, I also prefer to "avoid stranded
>quotes". If there is going to be quite a bit of building such strings, I
>prefer to do this:
>
>Function SQuote(BaseString as String)  as String
>    SQuote = Chr$(39) & BaseString & Chr$(39)
>EndFunction
>
>Function DQuote(BaseString as String)  as String
>    DQuote = Chr$(34) & BaseString & Chr$(34)
>EndFunction
>
>
>Then I use:
>
>stLinkCriteria = "[KundenName]=" & SQuote(Me![KundenName]) & " And
>[VerbandNr]=" &  Me![VerbandNr]
>
>or
>
>stLinkCriteria = "[KundenName]=" & DQuote(Me![KundenName]) & " And
>[VerbandNr]=" &  Me![VerbandNr]
>
>
>
>On 27 Jan 2004 at 18:46, Brett Barabash wrote:
>
> > Personally, (and this is simply preference, I'm sure others will argue) I
> > prefer also avoiding "stranded" quotes, so
> >
> > stLinkCriteria = "[KundenName]=" & "'" & Me![KundenName] & "'" & " And
> > [VerbandNr]=" & Me![VerbandNr]
> >
> > Becomes:
> >
> > stLinkCriteria = "[KundenName]='" & Me![KundenName] & "' And 
> [VerbandNr]=" &
> > Me![VerbandNr]
> >
> > Less string concatenation that way.  The only catch is if your code window
> > uses a sans serif font like Arial, Tahoma, etc, the quotes tend to mush
> > together making my method less readable.  Otherwise, I find it much easier
> > to debug.
> >
> >
> > -----Original Message-----
> > From: Helmut.E.Kotsch at t-online.de [mailto:Helmut.E.Kotsch at t-online.de]
> > Sent: Tuesday, January 27, 2004 6:23 PM
> > To: Access Developers discussion and problem solving
> > Subject: AW: [AccessD] Concatenated stLinkCritria produces Type
> > mismatcherror.
> >
> >
> > Charlotte you are great. Thank you very much. Here I'm sitting at midnight
> > in Germany defining my problem and there you come back within minutes 
> with a
> > workable solution.
> > What is the alternative to using multiple double quotes? (I don't like them
> > either)
> > Where in the world would someone learn / read about the solution you
> > provided. Even though it works, I don't understand it.
> > To be honest, this whole "quotes syntax" (single and double) is a nightmare
> > to me.
> >
> > Again, thanks a lot.
> > Regards and have a nice day.
> >
> > Helmut Kotsch
> >
> > (Helmut.E.Kotsch at t-online.de)
> >
> >
> > -----Ursprungliche Nachricht-----
> > Von: accessd-bounces at databaseadvisors.com
> > [mailto:accessd-bounces at databaseadvisors.com]Im Auftrag von Charlotte
> > Foust
> > Gesendet: Mittwoch, 28. Januar 2004 00:49
> > An: Access Developers discussion and problem solving
> > Betreff: RE: [AccessD] Concatenated stLinkCritria produces Type
> > mismatcherror.
> >
> >
> > I don't like to use multiple double quotes like that because it's so
> > hard to read.  Your problem is in this line:
> >
> >    stLinkCriteria = "[KundenName]=" & "'" & Me![KundenName] & "'" And
> > "[VerbandNr]=" & Me![VerbandNr]
> >
> > Which should be:
> >
> >    stLinkCriteria = "[KundenName]=" & "'" & Me![KundenName] & "'"  & "
> > And [VerbandNr]=" & Me![VerbandNr]
> >
> > Charlotte Foust
> >
> > -----Original Message-----
> > From: Helmut Kotsch [mailto:Helmut.E.Kotsch at t-online.de]
> > Sent: Tuesday, January 27, 2004 3:11 PM
> > To: accessd at databaseadvisors.com
> > Subject: [AccessD] Concatenated stLinkCritria produces Type mismatch
> > error.
> >
> >
> > Hi,
> > I am trying to open a form where 2 conditions have to be met. When only
> > one conditon (as shown in code below as sample#1 and sample#2) is set
> > than it works ok.
> >
> > Sample#1  ==> OK
> >
> >     Dim stDocName As String
> >     Dim stLinkCriteria As String
> >     stDocName = "VERDI-Kunden"
> >     stLinkCriteria = "[KundenName]=" & "'" & Me![KundenName] & "'"
> >     DoCmd.OpenForm stDocName, , , stLinkCriteria
> >
> > Sample#2 ==> OK
> >
> >     Dim stDocName As String
> >     Dim stLinkCriteria As String
> >     stDocName = "VERDI-Kunden"
> >     stLinkCriteria = "[VerbandNr]=" & Me![VerbandNr]
> >     DoCmd.OpenForm stDocName, , , stLinkCriteria
> >
> > However when concatenating both conditions as shown in the following
> > code I get a "Type mismatch" error.
> >
> >     Dim stDocName As String
> >     Dim stLinkCriteria As String
> >     stDocName = "VERDI-Kunden"
> >     stLinkCriteria = "[KundenName]=" & "'" & Me![KundenName] & "'" And
> > "[VerbandNr]=" & Me![VerbandNr]
> >     DoCmd.OpenForm stDocName, , , stLinkCriteria
> >
> > Hope someone can help before this one drives me grazy.
> >
> >
> > Helmut Kotsch




More information about the AccessD mailing list