Hello,
I have been trying to solve this issue for long and need help from you guys!
Here is the point:
Looking to get the following SQL into VBA:
SELECT Securities.Name, Securities.ISIN
FROM Securities
WHERE (((Securities.Name) Like [Forms]![Securities Search tool]![namecombo] & "*"))
Apparently my WHERE condition syntax is wrong: - "WHERE (([name] Like " Me.namecombo " & "*" & ")"
"Namecombo" is the name of a combo box
PLease help debug!
Thanks!!!
10 7863
Try this ... -
"WHERE (([Securities].[Name]) Like '" & Me.namecombo & "*" & "')"
-
Mary
NeoPa 32,556
Expert Mod 16PB
Maybe Evans has a point about all that whiskey!
Try : - "WHERE ([Name] Like '" & Me.namecombo & "*')"
(a small slip in truth.)
You can add [Securities]. before [Name] too if you like. It is optional in this context.
Maybe Evans has a point about all that whiskey!
Try : - "WHERE ([Name] Like '" & Me.namecombo & "*')"
(a small slip in truth.)
You can add [Securities]. before [Name] too if you like. It is optional in this context.
Now Ade
It would have worked anyway
Mary
NeoPa 32,556
Expert Mod 16PB
Now Ade
It would have worked anyway
Mary
I know :(.
I was being fussy - but it was fun :)
I know :(.
I was being fussy - but it was fun :)
go get ready to go out and stop checking up on me. ;)
Mary
Thanks for help.
Now you can enjoy the week-end.
Here is the code I used to requery the dropdown list of a combo while typing: - Private Sub Setnamecbo()
-
Dim strcboSQL As String
-
Dim strWhere As String
-
Dim itemVal As Variant
-
Dim accListcbo() As Variant
-
Dim lngLen As Long
-
Dim msg As String
-
-
-
strcboSQL = ""
-
[namecombo].SetFocus
-
-
strcboSQL = "SELECT [Name], [Coupon rate], [Maturity DD/MM], [Curr], [Type], [ISIN], [Bloomberg]" & vbCrLf & _
-
"FROM [Securities]" & vbCrLf & _
-
"WHERE ([Name] Like '" & "*" & Me.namecombo.Text & "*')"
-
With Me.Typelist
-
For Each itemVal In Me.Typelist.ItemsSelected
-
If Not IsNull(itemVal) Then
-
strWhere = strWhere & """" & .ItemData(itemVal) & """, "
-
End If
-
Next
-
End With
-
lngLen = Len(strWhere) - 2 'Without trailing comma and space.
-
If lngLen > 0 Then
-
strWhere = "[type] IN (" & Left$(strWhere, lngLen) & ")"
-
strcboSQL = strcboSQL & " AND " & strWhere
-
End If
-
-
-
strcboSQL = (strcboSQL & vbCrLf & "ORDER BY [name];")
-
'msg = MsgBox(strcboSQL, vbInformation)
-
-
-
Me.namecombo.RowSource = strcboSQL
-
-
End Sub
-
-
I'm glad you got it working. Now I'm going to take a leaf out of Adrians book and be a little pedantic. :D
You don't need to use the vbCrLf command in any of the query. -
Private Sub Setnamecbo()
-
Dim strcboSQL As String
-
Dim strWhere As String
-
Dim itemVal As Variant
-
Dim accListcbo() As Variant
-
Dim lngLen As Long
-
Dim msg As String
-
-
strcboSQL = ""
-
[namecombo].SetFocus
-
-
strcboSQL = "SELECT [Name], [Coupon rate], [Maturity DD/MM], [Curr], [Type], [ISIN], [Bloomberg]" & _
-
"FROM [Securities]" & _
-
"WHERE ([Name] Like '*" & Me.namecombo.Text & "*')"
-
With Me.Typelist
-
For Each itemVal In Me.Typelist.ItemsSelected
-
If Not IsNull(itemVal) Then
-
strWhere = strWhere & "'" & .ItemData(itemVal) & "', "
-
End If
-
Next
-
End With
-
lngLen = Len(strWhere) - 2 'Without trailing comma and space.
-
If lngLen > 0 Then
-
strWhere = "[type] IN (" & Left$(strWhere, lngLen) & ")"
-
strcboSQL = strcboSQL & " AND " & strWhere
-
End If
-
-
strcboSQL = (strcboSQL & "ORDER BY [name];")
-
'msg = MsgBox(strcboSQL, vbInformation)
-
-
Me.namecombo.RowSource = strcboSQL
-
-
End Sub
-
-
Mary
NeoPa 32,556
Expert Mod 16PB
This sounds like I'm posting for the sake of it but I'm really not.
I've seen this happen before ...
Mary is right about the VbCrLf but you should also understand that while SQL interprets any white-space (Characters which don't produce any characters printed but simply reposition where the next character would be printed) equally, and multiple white-space characters qualify the same as a single one, An example of a white-space character should be used to separate the items previously separated by the VbCrLf.
That's the long version for anyone who's curious, the short version is 'Don't forget to replace any VbCrLfs with tab or space characters if you remove them'.
thank you guys for this great "cursus"
I feel like a genius at VB now :)
thank you guys for this great "cursus"
I feel like a genius at VB now :)
Try answering a few simple questions here. You may surprise yourself.
Mary
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Andrey Tatarinov |
last post by:
Hi.
It would be great to be able to reverse usage/definition parts in
haskell-way with "where" keyword. Since Python 3 would miss lambda, that
would be extremly useful for creating readable...
|
by: HeadScratcher |
last post by:
I am trying to speed up my update statements by removing inner select
statements.
Example:
update orders set shipname = (select contactName from
customers where customerid = orders.customerID)...
|
by: kosta |
last post by:
hello! one of my forms communicates with a database, and is
supposed to add a row to a table using an Insert
statement... however, I get a 'oledb - syntax error'
exception... I have double...
|
by: eman1000 |
last post by:
I was recently looking at the prototype library
(http://prototype.conio.net/) and I noticed the author used the
following syntax:
Object.extend(MyObj.prototype, {
my_meth1: function(){},...
|
by: Steven Bethard |
last post by:
The PEP below should be mostly self explanatory. I'll try to keep the
most updated versions available at:
http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
|
by: Steven Bethard |
last post by:
I've updated the PEP based on a number of comments on comp.lang.python.
The most updated versions are still at:
http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
|
by: Steven Bethard |
last post by:
Ok, I finally have a PEP number. Here's the most updated version of the
"make" statement PEP. I'll be posting it shortly to python-dev.
Thanks again for the previous discussion and suggestions!...
|
by: Steven Bethard |
last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The
patch is available at:
http://bugs.python.org/1472459
and I've pasted the full text below.
I've tried to be more explicit about...
|
by: Heiko Wundram |
last post by:
Hi all!
The following PEP tries to make the case for a slight unification of for
statement and list comprehension syntax.
Comments appreciated, including on the sample implementation.
===...
|
by: florian.loitsch |
last post by:
According to the spec Section 14 the production
SourceElements:SourceElements SourceElement is evaluated as follows:
1. Evaluate SourceElements.
2. If Result(1) is an abrupt completion, return...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |