macro  input box

Posted on 2013-10-27
Last Modified: 2013-10-28

the below is code that allows me to input the exact sql query I want to parse in excel from my oracle db

 strSQL = InputBox(Prompt:="Your required result set.", _
          Title:="ENTER YOUR QUERY", Default:="Your Query here")

        If strSQL = "Your query here" Or _
           strSQL = vbNullString Then

however I want to hardcode the first part of the query and only want the where clause contained in the input box

i.e.  "select * from tablename " is fixed and non editable, I do want the where clause to be editable so basically have it like so:

select * from tablename where   + strSQL

strSQL = InputBox(Prompt:="Your where clause.", _
          Title:="ENTER YOUR WHERECLAUSE", Default:="Your where clause here")

        If strSQL = "Your where clause" Or _
           strSQL = vbNullString Then

How do I do this?

Question by:rutgermons
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 27

Accepted Solution

MacroShadow earned 500 total points
ID: 39604410
strSQL = yourSQL & InputBox(Prompt:="Your where clause.", _
          Title:="ENTER YOUR WHERECLAUSE", Default:="Your where clause here")
 If strSQL = "Your where clause" Or _
           strSQL = vbNullString Then
LVL 52

Expert Comment

ID: 39604887


in your code strSql cannot be null, I've also corrected the test for the default value

pls try
strResult = InputBox(Prompt:="Your where clause.", _
          Title:="ENTER YOUR WHERECLAUSE", Default:="Your where clause here")
 If strResult = "Your where clause here" Or _
           strResult = vbNullString Then
strSQL = yourSQL & strResult 

Open in new window


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

634 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