Solved

macro  input box

Posted on 2013-10-27
2
278 Views
Last Modified: 2013-10-28
Folks

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?

cheers
0
Comment
Question by:rutgermons
2 Comments
 
LVL 26

Accepted Solution

by:
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
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 39604887
Hi

@MacroShadow

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

Regards
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

747 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

12 Experts available now in Live!

Get 1:1 Help Now