By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,656 Members | 1,882 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,656 IT Pros & Developers. It's quick & easy.

Sort order

P: 29
Here is what i have

I have 2 cbo boxes cboHomeArea and cboResName
I want it to sort after update the
by [resid].[last]

currentlly it is defaulted to [Resid].[resid]
any help would be great


Private Sub cboHomeArea_AfterUpdate()
Dim sManagerSource As String
sManagerSource = "SELECT [ResID].[ResID]," & _
"[resid].[homeareaid]," & _
"[resid].[last]&', '&[resid].[first]" & _
"FROM resid " & _
"WHERE [homeAreaId] = " & Me.cboHomeArea.Value
Me.cboResName.RowSource = sManagerSource
Me.cboResName.Requery

End Sub
Jan 22 '08 #1
Share this Question
Share on Google+
8 Replies


P: 29
Any help would be great
Jan 23 '08 #2

P: 29
I could use a little help with this
Feb 5 '08 #3

Rabbit
Expert Mod 10K+
P: 12,421
Use the ORDER BY clause.

Expand|Select|Wrap|Line Numbers
  1. SELECT Field1
  2. FROM Table1
  3. ORDER BY Field2;
  4.  
Feb 5 '08 #4

P: 29
i know the syntax... but it after running it with an orderby it shows me nothing
that or it says improper use of data... im not good with VBA to begin with but i think its pretty self explainitory

dim sMangerSource as string

smanagersource="Select [resid].[resid]," & _
"[resid.last]&', '&[resid].[first]," & _
"[resid].[homearea]" &-
"from [resid]"
"where [resid].[homearea]=" me.Homeareacbo.value & _
"order by [resid].[last]"
Me.cboResName.RowSource = sManagerSource
Me.cboResName.Requery

but this is not right..... why...
Feb 7 '08 #5

Rabbit
Expert Mod 10K+
P: 12,421
Your spacing is off.

Expand|Select|Wrap|Line Numbers
  1. "SELECT *" & "FROM" & "Table1;"
  2.  
will give you
[code=sql]
SELECT *FROMTable1;"
Feb 7 '08 #6

P: 29
Your spacing is off.

Expand|Select|Wrap|Line Numbers
  1. "SELECT *" & "FROM" & "Table1;"
  2.  
will give you
[code=sql]
SELECT *FROMTable1;"
I really appreciate the help Rabbit
but. .. i think i need some more training before i battle VBA... this simple code isn't working no matter which way i write it...

thanks anyway
Feb 8 '08 #7

Rabbit
Expert Mod 10K+
P: 12,421
All you need to do is get your spacing correct:

Expand|Select|Wrap|Line Numbers
  1. dim sMangerSource as string
  2.  
  3. smanagersource="Select [resid].[resid]," & _
  4. "[resid.last] & ', ' & [resid].[first]," & _
  5. "[resid].[homearea] " & _
  6. "from [resid] " & _
  7. "where [resid].[homearea]=" me.Homeareacbo.value & _
  8. " order by [resid].[last];"
  9. Me.cboResName.RowSource = sManagerSource
  10. Me.cboResName.Requery
  11.  
Feb 8 '08 #8

P: 29
Thanks ever so much.. i finnally got it to work.... you where very right the spacing was off..

These little things can cause so much trouble
Feb 19 '08 #9

Post your reply

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