![]() | |
#11
| |||
| |||
|
| "PW" <emailaddyinsig (AT) ifIremember (DOT) com> wrote in message news:g6m4f7p9cnsu7e7hjqc5taksnhnd7fc2bh (AT) 4ax (DOT) com... On Wed, 21 Dec 2011 14:05:21 -0600, "Ron Paii" <None (AT) none (DOT) com> wrote: "PW" <emailaddyinsig (AT) ifIremember (DOT) com> wrote in message news:8g74f7lgf2dme6glajei3f67o2ptvtmecq (AT) 4ax (DOT) com... On Wed, 21 Dec 2011 05:44:43 -0800 (PST), FireyColin colin.mardell (AT) btopenworld (DOT) com> wrote: Thankyou Patrick I've been trying that using the following code: Dim StrValue1 As String StrValue1 = [Forms]![frmPolicy]![txtPolicyNo] DoCmd.OpenForm "frmPolicy", acNormal, , , "policy_no = StrValue1" but just comes back with 'Type mismatch' I stink at string syntax, but maybe this will work: "[policy_no] = ' " & strValue1 &" ' " -pw PW's syntax should work; Hey - it's right out of Getz's Access 97 Handbook! :-) I wish he went into more explanation though. I think the explanation would be in how SQL and VBA handles strings more then Access. In this case StrValue1 is a local variable so when you attempt use it in a form filter "policy_no = StrValue1", SQL has no access to the variable. But with "[policy_no] = ' " & strValue1 &" ' ", you are concatenating the string stored in strValue1 into the SQL. The extra quotes you are adding are required by SQL so it doesn't try to interpret the strValue1 string as a SQL statement. |
#12
| |||
| |||
|
|
I find recordsetclone much more reliable. |
#13
| |||
| |||
|
|
Patrick Finucane wrote: My rule of thumb is Strings get surrounded in qutes Dates get surrounded in # Numbers don't get surrounded I used to have a canned response covering this somewhere. Let's see if I can find it ... Ah! Here it is: To decide whether or not to delimit the data, look at the datatype of the 4.Lastly, if you are using LIKE, you need to be aware that you must use % and _ as the wildcards, not * and ?. This is true no matter what database you are using Interesting, but are you sure you're correct about the "LIKE" clause? |
#14
| |||
| |||
|
|
Patrick Finucane wrote: 4.Lastly, if you are using LIKE, you need to be aware that you must use % and _ as the wildcards, not * and ?. This is true no matter what database you are using Interesting, but are you sure you're correct about the "LIKE" clause? |
#15
| |||
| |||
|
|
On 22/12/2011 14:06:43, "Bob Barrows" wrote: Patrick Finucane wrote: My rule of thumb is Strings get surrounded in qutes Dates get surrounded in # Numbers don't get surrounded I used to have a canned response covering this somewhere. Let's see if I can find it ... Ah! Here it is: To decide whether or not to delimit the data, look at the datatype of the 4.Lastly, if you are using LIKE, you need to be aware that you must use % and _ as the wildcards, not * and ?. This is true no matter what database you are using Interesting, but are you sure you're correct about the "LIKE" clause? For years (Access 2 to Access 2010) I have had a form with a field called "Filter" - I know, probably a reserved word but it has [] round it, so no problem. This can be set to "A*", "B*" etc or just plain "*" The query that is the RowSource for a list box has the line "WHERE (MemSurName Like [Screen].[ActiveForm]![Filter]) ". Works perfectly OK Phil |
#16
| |||
| |||
|
|
Phil wrote: On 22/12/2011 14:06:43, "Bob Barrows" wrote: Patrick Finucane wrote: My rule of thumb is Strings get surrounded in qutes Dates get surrounded in # Numbers don't get surrounded I used to have a canned response covering this somewhere. Let's see if I can find it ... Ah! Here it is: To decide whether or not to delimit the data, look at the datatype of the 4.Lastly, if you are using LIKE, you need to be aware that you must use % and _ as the wildcards, not * and ?. This is true no matter what database you are using Interesting, but are you sure you're correct about the "LIKE" clause? For years (Access 2 to Access 2010) I have had a form with a field called "Filter" - I know, probably a reserved word but it has [] round it, so no problem. This can be set to "A*", "B*" etc or just plain "*" The query that is the RowSource for a list box has the line "WHERE (MemSurName Like [Screen].[ActiveForm]![Filter]) ". Works perfectly OK Phil In a query run in Access, Jet wildcards are used. I believe I mentioned that somewhere else in that message. If not, my apologies. As for code that connects to Jet from external sources, as Douglas says, whether DAO or ADO is being used is the key. The canned message was intended for an asp group where ADO is exclusively used instead of DAO (due to the single-threaded structure of the DAO dll), so either the ODBC Jet driver or the native Jet OLE DB provider is used, both of which require ODBC wildcards. They translate the wildcards to Jet wildcards before passing a query along to Jet to be run. |
![]() |
| Thread Tools | |
| Display Modes | |
| |