Prev: msflex grid ocx 64 bit?
Next: nothing
From: Neil on 21 Apr 2010 19:08 Hi, I am using the following code in the after update event of a combo box [cboregion] to sync another combo box [Combo5], it all works except when the first "if" is true it doesn't sort the salesman. I have tried putting the ORDER BY[Salesman] in but cannot get it to work. I am stumped on how to sort by salesman and help would be appreciated Dim sSource As String If Me.cboRegion.Value <> 10 Then sSource = "SELECT [tblsalesman].[ID], [tblsalesman].[region], [tblsalesman].[salesman] " & _ "FROM tblSalesman " & _ "WHERE [region] = " & Me.cboRegion.Value Me.Combo5.RowSource = sSource Else Me.Combo5.RowSource = "SELECT [tblsalesman].[ID], [tblsalesman].[Region], [tblsalesman].[salesman] FROM tblSalesman ORDER BY [Salesman]" End If Me.Combo5.Requery thanks in advance Neil
From: Duane Hookom on 21 Apr 2010 20:08 How about Dim sSource As String If Me.cboRegion.Value <> 10 Then sSource = "SELECT [ID], [region], [salesman] " & _ "FROM tblSalesman " & _ "WHERE [region] = " & Me.cboRegion.Value Else sSource = "SELECT [ID], [Region], [salesman] " & _ "FROM tblSalesman " End If Me.Combo5.RowSource = sSource & " ORDER BY Salesman" -- Duane Hookom MS Access MVP "Neil" <naeves_noreply(a)gmail.com> wrote in message news:9DBA576F-254E-40AB-A3D0-532BE94F6111(a)microsoft.com... > Hi, > I am using the following code in the after update event of a combo box > [cboregion] to sync another combo box [Combo5], it all works except when > the first "if" is true it doesn't sort the salesman. I have tried putting > the ORDER BY[Salesman] in but cannot get it to work. > > I am stumped on how to sort by salesman and help would be appreciated > > Dim sSource As String > If Me.cboRegion.Value <> 10 Then > sSource = "SELECT [tblsalesman].[ID], [tblsalesman].[region], > [tblsalesman].[salesman] " & _ > "FROM tblSalesman " & _ > "WHERE [region] = " & Me.cboRegion.Value > Me.Combo5.RowSource = sSource > Else > Me.Combo5.RowSource = "SELECT [tblsalesman].[ID], > [tblsalesman].[Region], [tblsalesman].[salesman] FROM tblSalesman ORDER BY > [Salesman]" > End If > Me.Combo5.Requery > > > thanks in advance > Neil
From: Neil on 21 Apr 2010 20:36 Thanks very much, works a treat. Neil "Duane Hookom" <duanehookom(a)gmail.com> wrote in message news:2EEE90CC-DE32-4AC6-B782-9C16CE377332(a)microsoft.com... > How about > Dim sSource As String > If Me.cboRegion.Value <> 10 Then > sSource = "SELECT [ID], [region], [salesman] " & _ > "FROM tblSalesman " & _ > "WHERE [region] = " & Me.cboRegion.Value > Else > sSource = "SELECT [ID], [Region], [salesman] " & _ > "FROM tblSalesman " > End If > Me.Combo5.RowSource = sSource & " ORDER BY Salesman" > > > -- > Duane Hookom > MS Access MVP > > > "Neil" <naeves_noreply(a)gmail.com> wrote in message > news:9DBA576F-254E-40AB-A3D0-532BE94F6111(a)microsoft.com... >> Hi, >> I am using the following code in the after update event of a combo box >> [cboregion] to sync another combo box [Combo5], it all works except when >> the first "if" is true it doesn't sort the salesman. I have tried putting >> the ORDER BY[Salesman] in but cannot get it to work. >> >> I am stumped on how to sort by salesman and help would be appreciated >> >> Dim sSource As String >> If Me.cboRegion.Value <> 10 Then >> sSource = "SELECT [tblsalesman].[ID], [tblsalesman].[region], >> [tblsalesman].[salesman] " & _ >> "FROM tblSalesman " & _ >> "WHERE [region] = " & Me.cboRegion.Value >> Me.Combo5.RowSource = sSource >> Else >> Me.Combo5.RowSource = "SELECT [tblsalesman].[ID], >> [tblsalesman].[Region], [tblsalesman].[salesman] FROM tblSalesman ORDER >> BY [Salesman]" >> End If >> Me.Combo5.Requery >> >> >> thanks in advance >> Neil >
|
Pages: 1 Prev: msflex grid ocx 64 bit? Next: nothing |