Solved difficulty when highlighting a variable from a long sql query in VBA editor (1 Viewer)

allanc

Registered User.
Local time
Today, 05:53
Joined
Nov 27, 2019
Messages
46
Hello Friends!

Let's say I have a line of code like this below:

Set rs1 = New ADODB.Recordset
rs1.Open "SELECT * FROM
WHERE [Column1] = " & [Variable1] & " AND [Column2]= '" & [Variable2] & "' AND ................[Column10] = '" & [VARIABLE10].Value &", CurrentProject.Connection, adOpenStatic, adLockOptimistic, adCmdText


I am having a difficult time highlighting part of this SQL query - somehow VBA editor is selecting the entire line for me.

e.g I want to select variable10 to copy, it's going to select the entire line of code........I have to be really slow when I select and often it takes couple attempts.

I think this only happens when I try to select part of the codes in a SQL query...because I had no issues selecting couple words from the code below:

string1 = "hello i think this can be a long code so i want to see if this issue is only happening when it's a sql query. adding couple more words to make this long enough"

Is there an option to disable this auto-selecting? A colleague has suggested to break the codes to couple lines - I believe this will solve the problem but I wanted to check to see if there's any better solutions.

Thanks!
Allan
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:53
Joined
Sep 21, 2011
Messages
14,038
You can just double click that variable name to select all of it.?
If you hold the shift key down you can click either side and extend the selected text.?

HTH
 

allanc

Registered User.
Local time
Today, 05:53
Joined
Nov 27, 2019
Messages
46
You can just double click that variable name to select all of it.?
If you hold the shift key down you can click either side and extend the selected text.?

HTH

Thanks a lot for your help!

Holding shift works pretty well - this is really useful!

Double-clicking will certainly help in certain situations(selecting the variable only) but I am usually selecting the quotation marks as well.

e.g '" & [Variable A] & "'
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:53
Joined
Sep 21, 2011
Messages
14,038
Yes not ideal I admit, I actually use a mouse on a sofa arm :) and I find, if not careful that the selected text will reverse from my selection to select the unselected text. :(

In fact if you select the quotes first then shift and click next set of quotes, you will get all of that required.
 
Last edited:

Micron

AWF VIP
Local time
Today, 05:53
Joined
Oct 20, 2018
Messages
3,476
In my vbe, ['s are considered as delimiters when selecting using the keyboard. If not for that, ctrl+shift+right arrow would select the whole word if you were at the left side of it (this usually works in other apps too). So ctrl+shift+ra+ra+ra (3 quick right arrow presses) gets you the word and the [ ]'s.
EDIT - fixed because I got my left/rights mixed up.
 

Users who are viewing this thread

Top Bottom