Query input unintentionally parsed.

Arrows

New Member
Joined
Jan 25, 2005
Messages
2
I have a table in a database that contains 100+ numbered, multiple-choice questions and a user query that allows the user to type in one or several question numbers. The intended result of the query is a report listing each selected question and their associated answers. It is to allow the instructor to tailor a mini-quiz from the master database.

However, when the user enters any two digit number (eg 13) the result generated is the intended number plus the individual components (1, 3, 13 instead of just 13).

I am using the query: Expr1: InStr(1,[Enter question numbers separated by commas],[Tbl_Questions.Key])

I have a solution but it requires two queries. One query for questions 1-9 and another for questions 10-99 but this is not really acceptable to me or my colleagues since both values <10 and >10 are expected to be entered into a single query.

Is this doable or am I asking the impossible?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Yes it is.
What you do is build a custom function that handles both conditions.
As an explanation, think of all the built-in functions in a product like Excel. Sum, MAX, MIN, etc. They all do a complex task..well, you get to define that task.

In your query, you'll end up putting something like:

functionname([fieldname1])

Your code will probably look something like:

Code:
Function functioname(ByVal aname As String) As String

If (test variable aname) = condition Then
  'functioname = some calculation you do
else
   'functioname = other calculation
End if

End Function

Mike
 
Upvote 0

Forum statistics

Threads
1,221,848
Messages
6,162,404
Members
451,762
Latest member
Brainsanquine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top