473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

combo box, selection, sql

I am creating a combo box with a button. In the below vba code, I am getting the string from the combo box. Then, I am trying to use SQL to the corresponding distro lists in the table (same row). This VBA code below is getting a Run-time error '438' Object doesn't support this property or method and it points to the SQL statment in the debugging screen. Any help is greatly appreciated.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Command11_Click()
  2. Dim cnn As ADODB.Connection
  3.   Dim rs As ADODB.Recordset
  4.   Dim SQL As String
  5.   Dim vFld As Variant
  6.  
  7. string1 = Combo27.Value
  8.  
  9. SQL = "SELECT [" & DistributionLists & "]  as Fld" & _
  10. " FROM " & DistroLists & " WHERE " & string1 & "=" & Application
  11.  
  12.  
  13.   rs.Open SQL
  14.  
  15.   vFld = rs!Fld
  16.  
  17.   Set cnn = Nothing
  18.   Set rs = Nothing
  19.  
  20.  
  21.  
  22. MsgBox (vFld)
  23.  
  24.  
  25. End Sub
  26.  
Jun 21 '13 #1
1 1295
zmbd
5,501 Expert Mod 4TB
Ok,
1) (...) & string1 & "=" & Application (...) this is more than likely your issue in that Application is a token word the refers to, well, the program and you've not used it correctly.

2) once you get the SQL line fixed, you might insert at line11 debug.print sql if your code crashes press <ctrl+g>, C&P the resulting string to a post here

3) please read and follow everything within the following link. Remember that you may have to repeat the compile and fix error steps several times until you can compile without any errors: >> Before Posting (VBA or SQL) Code.

4) The articles on Form Filter and Cascasde will provide you with a lot of information and may very well help you solve the issue.
From the Bytes > Sitemap > Microsoft Access / VBA Insights
42.Cascaded Form Filtering
156.Cascading Combo/List Boxes
168.Example Filtering on a Form.
Jun 21 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Alex | last post by:
Acc97.. I have a database which records down-time on 8 machines, the selection of reasons comes from a combo box. I have tried to be clever! and limit the options relative to each machine within...
4
by: Rob | last post by:
Is it possible to have a field in a table ( A) such as social security # that takes a number as data. It is linked to a table (B) that has the Name and SSN in it for the combo box drop down with...
6
by: sea# | last post by:
I'm trying to use a combo box on a windows form which will change its display on event of changing combo selection. This is the method I wrote: Wrote this code: private void...
1
by: reshma | last post by:
I have one password field, confirm password field, combo box in one panel. There are 2 more panels - one for individual and another for corporate. After entering password and confirm password, i...
2
by: Schultzy | last post by:
I think Kazza has the same problem. I am very new at this I also need to get the values from the combo selection and put them in a table I've tried to put the line in the criteria but I don't...
1
by: Yvonne | last post by:
We have a Contacts database which categorises our Contacts by three categories eg Country, Language and Skills. It has a combo box ( not bound) which is populated from a union query that gets its...
3
by: Sukesh Kumar Sharma | last post by:
Iam an avid user of Access. When I use a Combo box in a form to view certain records based on the combo selection, how to use All option in combo box to view all the records. Please help me.
1
by: didihynes | last post by:
Hi Guys, I'm in desparate need of help. I am producing a database for my dissertation and have got majorly stuck. I am currently creating a form in which the user will select a student from a...
6
by: David Wright | last post by:
Hello Folks I am using Microsoft Access 2000 I would be grateful if someone could help me with “Dlookup”. I tried various methods of writing Dlookup and various events to trigger it, none of...
4
by: dekk | last post by:
I am trying to populate a text field from the combo selection. I have the following update event in the combo box Private Sub cboContract_AfterUpdate() Me!txtDesc = Me!cboContract.Column(1)...
1
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...
0
isladogs
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...
0
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.