Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Using LIKE expression with controls

Author  Topic 

RoyPaun
Starting Member

13 Posts

Posted - 2009-07-15 : 20:05:37
If I execute the foloowing:
DoCmd.OpenForm "TapasForm", , , " [Member spare table].[First Name] Like '" & Me.txtSearch2 & "*'"
there is no problem. Equally, if I run the expression
" [Member spare table.Surname] Like '" & Me.txtSearch & "*'" it also executes correctly. However, if I try
DoCmd.OpenForm "TapasForm", , , " [Member spare table].[First Name] Like '" & Me.txtSearch2 & "*'" And ("[Member spare table].[First Name] = " & Me.txtSearch2)
I get an error 'Type mismatch' (run time error 13). Me.txtsearch(2) are both controls. Any advice would be appreciated.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-15 : 20:10:29
DoCmd.OpenForm "TapasForm", , , "[Member spare table].[First Name] Like '" & Me.txtSearch2 & "*'" And [Member spare table].[First Name] = '" & Me.txtSearch2 & "'"



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

RoyPaun
Starting Member

13 Posts

Posted - 2009-07-15 : 21:01:12
Many thanks for the very quick reply, Peso. When I copied and pasted your text it came up with a compile "syntax error. So far I have been unable to determine what it is!!!! But still trying.
Go to Top of Page

RoyPaun
Starting Member

13 Posts

Posted - 2009-07-15 : 21:14:11
Have tried this (inserting brackets)
DoCmd.OpenForm "TapasForm", , , "[Member spare table].[First Name] Like '" & Me.txtSearch2 & "*'" And ("[Member spare table].[First Name] = '" & Me.txtSearch2 & "'")
but I still get a Type mismatch error.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-16 : 04:31:41
That's be´case your paranthesises are not part of the string.

DoCmd.OpenForm "TapasForm", , , "[Member spare table].[First Name] Like '" & Me.txtSearch2 & "*' And [Member spare table].[First Name] = '" & Me.txtSearch2 & "'"



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

RoyPaun
Starting Member

13 Posts

Posted - 2009-07-16 : 05:43:32
Many thanks indeed Peso. I changed one of the controls (!!!!), but it worked perfectly. Very grateful for your help.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-16 : 05:51:37
You're welcome.

Did you have a control array before?

DoCmd.OpenForm "TapasForm", , , "[Member spare table].[First Name] Like '" & Me.txtSearch(2) & "*' And [Member spare table].[First Name] = '" & Me.txtSearch(2) & "'"



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -