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 51

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

752 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