Solved

Access 2010 Like Function

Posted on 2014-10-02
9
193 Views
Last Modified: 2014-10-02
I' using the following code:
DoCmd.OpenForm "frm_Legend", , , "[Symbol] Like " * "'" & Me.Scenario_Code & "'"

however I get an error message Run Time Error 13 Data Mismatch -- any thoughts on how to correct.
0
Comment
Question by:shieldsco
  • 4
  • 4
9 Comments
 
LVL 34

Expert Comment

by:PatHartman
ID: 40357937
Is Symbol a text field?  If it isn't, you can't use Like at all since Like implies a text field and you will get incorrect results if you are comparing to a numeric value or date.
Are you really passing a partial string?
Like is very inefficient so you never want to use it unless you actually need it.

If you are using Like because you want the symbol to be optional, then do the following instead:

If Me.Scenario_Code & "" = "" Then
    DoCmd.OpenForm "frm_Legend"
else
    DoCmd.OpenForm "frm_Legend", , , "[Symbol] Like " * "'" & Me.Scenario_Code & "'"
End If

Open in new window

0
 

Author Comment

by:shieldsco
ID: 40357982
Still get error 13.
I trying to drill down to another form and display the matching value.


Scenario_Code Field                       Symbol Field
CO01.03                                             CO

Compare the first 2 char of the scenario_code field with the Symbol field
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 40358001
DoCmd.OpenForm "frm_Legend", , , "[Symbol] Like '*" & Me.Scenario_Code & "'"
0
 

Author Comment

by:shieldsco
ID: 40358040
The code did not error but it did not find the Symbol code
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 10

Expert Comment

by:Gozreh
ID: 40358048
Scenario_Code Field                       Symbol Field
CO01.03                                             CO

if this is your example, you need to place the * by the end

DoCmd.OpenForm "frm_Legend", , , "[Symbol] Like '" & Me.Scenario_Code & "*'"
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 40358060
to make sure,
In your form you have the text CO01.03 and you are placing by the criteria CO
DoCmd.OpenForm "frm_Legend", , , "[Symbol] Like 'CO*'"
0
 

Author Comment

by:shieldsco
ID: 40358083
How about if we take the left 2 char of the Scenario_Code  field and compare to the 2 digit Symbol field or vice versa??
0
 
LVL 10

Accepted Solution

by:
Gozreh earned 500 total points
ID: 40358096
so you will need to use the left function
DoCmd.OpenForm "frm_Legend", , , "[Symbol] ='" & Left(Me.Scenario_Code,2) & "'"
0
 

Author Closing Comment

by:shieldsco
ID: 40358116
Worked Good -- Thanks
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now