|
-
Nov 11th, 2003, 11:11 AM
#1
Thread Starter
Fanatic Member
Easy question. (Solved)
Access:
I need to populate a combobox with a field from my query. However I want the first row to be "Show All" and everything after that to be from my query.
So I figure I need to put the results of my query into a string and append it to the end of my string that contains "Show All". Like this
MyRowSourceString = "Show All;Item1;Item2;Item3..."
Is there a way to do this?
Last edited by Avatarp; Nov 11th, 2003 at 01:01 PM.
-
Nov 11th, 2003, 11:22 AM
#2
Hyperactive Member
I usualy use UNION.
example, let's say that the field you want to populate is "Field1" from "Table1".
VB Code:
Combo1.RowSource = "Select ""(Show All)"" as Field1 From Table1 UNION Select Field1 From Table1"
in order for the (Show All) item to show on the top of the list, I use "(".
-
Nov 11th, 2003, 11:36 AM
#3
Thread Starter
Fanatic Member
There is an error somewhere in the syntax here?
Code:
cmboFlowMonth.RowSource = "SELECT ""(Show All)"" as SchedulerInputData.MonthEnd From SchedulerInputData UNION SchedulerInputData.MonthEnd From SchedulerInputData;"
SchedulerInputData is my query
MonthEnd is my field
-
Nov 11th, 2003, 01:00 PM
#4
Thread Starter
Fanatic Member
I solved it....
Set my combobox protery for RowSourceType to be "Value List"
then I opened a recordset of my query and populated a string with any unique dtaes. like so:
Code:
Dim MyMonthString As String
Dim MyDB As Database, rs As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set rs = MyDB.OpenRecordset("SchedulerInputData", dbOpenDynaset)
MyMonthString = "(All);"
rs.MoveFirst
Do While Not rs.EOF
CurrentItem = CStr(Format(rs!monthEnd, "mmmm yyyy"))
If InStr(MyMonthString, CurrentItem) = 0 Then
MyMonthString = MyMonthString + CurrentItem + ";"
End If
rs.MoveNext
Loop
cmboFlowMonth.RowSource = MyMonthString
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|