473,385 Members | 1,814 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.

Row Source of ComboBox Question

Hi fellow byters, I was wondering is it possible to combine a value list definition and an SQL query in the same line of the row Source of a combo box. The Value List does the trick for now but if a new operating system type is entered into the database i wish for the combo box to pick it up instead of adding it each time into a value list. The SQL works fine as well but i Wish to add the All Clause

Value List version
Expand|Select|Wrap|Line Numbers
  1. "Windows Business Proffesonal";"Windows XP Proffesonal";"All"
  2.  
SQL Query
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT pc_small_specs.operating_sysytem FROM pc_small_specs";"
  2.  
The following is giving errors but it shows what i wish the ComboBox to display
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT pc_small_specs.operating_sysytem FROM pc_small_specs";"All";
  2.  
Is this possible or should I be taking a different approach
Regards
Panteraboy
May 15 '08 #1
5 1949
NeoPa
32,556 Expert Mod 16PB
A different approach.

Create the data you need in a table and maintain that when and where necessary. You can even create a dummy type entry for "All".
May 15 '08 #2
Dead on NeoPa was worth asking.
regards panteraboy
May 16 '08 #3
NeoPa
32,556 Expert Mod 16PB
Pleased to help Paul :)
May 16 '08 #4
I took your advice NeoPa on using the dummy format. It took me a while to get my head around what you were saying but it works just fine. entered all as the model name and used the following

Expand|Select|Wrap|Line Numbers
  1. Dim model As String
  2. Set db = CurrentDb
  3. Set qdf = db.QueryDefs("Admin_query")
  4.  model = "='" & Me.CboFind.Value & "' "
  5.  If (Me.CboFind.Value = "All") Then
  6.  model = " Like '*' "
  7.  End If
  8.      strSQL = "SELECT pc_small_specs.* " & _
  9.          " FROM pc_small_specs " & _
  10.          " WHERE pc_small_specs.model" & model & _
  11.          " ORDER BY pc_small_specs.product_id;"
  12.  
  13.  
Thanks Again NeoPa
May 23 '08 #5
NeoPa
32,556 Expert Mod 16PB
No worries Paul. Glad it helped :)

BTW there's another technique you can use when you have filtering which is flexible (Sometimes you want to use wildcards but sometimes not). This works based on the fact that "X = 'Y'" is equivalent to "X Like 'Y'" whenever 'Y' has no wildcard characters embedded.

Your code could then be :
Expand|Select|Wrap|Line Numbers
  1. Dim model As String
  2.  
  3. Set db = CurrentDb
  4. Set qdf = db.QueryDefs("Admin_query")
  5.  
  6. model = Replace("Like '%V' ", "%V", IIf(Me.CboFind = "All", "*", Me.CboFind)
  7. strSQL = "SELECT * " & _
  8.          "FROM pc_small_specs " & _
  9.          "WHERE [model] " & model & _
  10.          "ORDER BY product_id;"
Does that make sense?
May 23 '08 #6

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

Similar topics

10
by: Mr. B | last post by:
I've been seeking the solution to this. But can't figure it out (sounds simple enough). When you Populat a ComboBox, you can select the initial displayed items on startup simply by setting the...
6
by: Georges Heinesch | last post by:
An easy ComboBox question. ;) I would like to create a ComboBox, which permits to cycle through 3 subforms. These 3 subforms are entered in the ComboBox as Value List. The subforms should only...
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
1
by: Jean | last post by:
Hi, I think this is quite a simple one: I have a ComboBox, where the source is a stored query. When I click the drop-down arrow on the Box, it takes awhile. I want to run this query in the...
4
by: David Sworder | last post by:
Hi, I have a ComboBox that contains 1,400 sorted items . Here's the list: abba apple ... cabba caccaa capple
4
by: Beeeeeeeeeeeeves | last post by:
I have an ownerdrawn combo box which I am drawing with an image and some text, this is all working beautifully apart from the difference in the Brush I have to draw the background and the text with...
0
by: Hiroyuki Tanaka | last post by:
Hi All, I am trying to develop an application for a touch screen using buttons for the numeric pad with Completion ComboBoxes. At the moment I am having a problem sending the button presses to...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
2
by: Newbie | last post by:
I have a combobox on a form. Coming from VB, I like to build a dynamic SQL statement and then set the control's data source to the SQL statement. Please tell me how to do that in access using...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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.