dbTalk Databases Forums  

Combo Box based on Query sort not working - A2K

comp.databases.ms-access comp.databases.ms-access


Discuss Combo Box based on Query sort not working - A2K in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sara
 
Posts: n/a

Default Combo Box based on Query sort not working - A2K - 02-27-2008 , 11:12 AM






Hi -

I have been asked to change a combo box display to sort in
alphabetical order. This is in an app I did not write, but it should
be simple enough!

The combo box is based on a table (and I've put in SQL and a query -
same problem)

It is 2 columns, bound column 1, width 0,2".

Query: SELECT Departments.DeptCode, Departments.DeptName
FROM Departments
ORDER BY Departments.DeptName;

When I run the SQL or the Query, stand-alone or from the properties
window, the sorting is correct (in Dept Name order).

The combo box still displays in DeptCode (Number) order.

I tried changing the number of rows to display (from 8 to 20) and the
column widths (to .5", 2") and nothing changes in the display! Still
shows 8 rows, in number order.

It's like it's not taking my changes or it's getting its direction for
the combo box from somewhere else.

Any ideas? Would a decompile be any help at all? There's lots of
code in the app, but little in the form and nothing with this combo
box.

Thanks -
Sara

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Combo Box based on Query sort not working - A2K - 02-27-2008 , 11:36 AM






sara wrote:
Quote:
Hi -

I have been asked to change a combo box display to sort in
alphabetical order. This is in an app I did not write, but it should
be simple enough!

The combo box is based on a table (and I've put in SQL and a query -
same problem)

It is 2 columns, bound column 1, width 0,2".

Query: SELECT Departments.DeptCode, Departments.DeptName
FROM Departments
ORDER BY Departments.DeptName;

When I run the SQL or the Query, stand-alone or from the properties
window, the sorting is correct (in Dept Name order).

The combo box still displays in DeptCode (Number) order.

I tried changing the number of rows to display (from 8 to 20) and the
column widths (to .5", 2") and nothing changes in the display! Still
shows 8 rows, in number order.

It's like it's not taking my changes or it's getting its direction for
the combo box from somewhere else.

Any ideas? Would a decompile be any help at all? There's lots of
code in the app, but little in the form and nothing with this combo
box.

Thanks -
Sara
You've verified that the SQL that works (listed above) is the rowsource
for the combo?

If so, open up the code editor and press CTRL+F and look for
YourComboBoxName.Rowsource =
or
.Rowsource =
in the form's module.

Since you didn't write the app, it is possible that someone updates the
rowsource elsewhere. If you find it, change it to reflect the right SQL
statement.

Bonafide
http://www.youtube.com/watch?v=-6IKA0FRpnE


Reply With Quote
  #3  
Old   
timmg
 
Posts: n/a

Default Re: Combo Box based on Query sort not working - A2K - 02-27-2008 , 11:48 AM



I assume that you're clicking on the rowsource button in the
properties window to edit the query, right?

Does the row source query change when you save and close the form and
then reopen it?

If you can change the rowsource to "SELECT Departments.DeptCode,
Departments.DeptName FROM Departments
ORDER BY Departments.DeptName;" but the next time you open the form
the order by clause is gone or different I'd look for an "On Open" or
"On Activate" event in the form that _may_ be resetting the
rowsource. If the order by clause is there all of the time we've got
other problems.

A decompile probably wont help, but it couldn't hurt (as long as you
have a good backup).

hth,
tim mills-groninger

On Feb 27, 11:12*am, sara <saraqp... (AT) yahoo (DOT) com> wrote:
Quote:
I have been asked to change a combo box display to sort in
alphabetical order. *This is in an app I did not write, but it should
be simple enough!
...

It is 2 columns, bound column 1, width 0,2".

Query: *SELECT Departments.DeptCode, Departments.DeptName
FROM Departments
ORDER BY Departments.DeptName;
...

Any ideas? *Would a decompile be any help at all? *There's lots of
code in the app, but little in the form and nothing with this combo
box.

Thanks -
Sara


Reply With Quote
  #4  
Old   
sara
 
Posts: n/a

Default Re: Combo Box based on Query sort not working - A2K - 02-27-2008 , 11:51 AM



On Feb 27, 12:36*pm, Salad <o... (AT) vinegar (DOT) com> wrote:
Quote:
sara wrote:
Hi -

I have been asked to change a combo box display to sort in
alphabetical order. *This is in an app I did not write, but it should
be simple enough!

The combo box is based on a table (and I've put in SQL and a query -
same problem)

It is 2 columns, bound column 1, width 0,2".

Query: *SELECT Departments.DeptCode, Departments.DeptName
FROM Departments
ORDER BY Departments.DeptName;

When I run the SQL or the Query, stand-alone or from the properties
window, the sorting is correct (in Dept Name order).

The combo box still displays in DeptCode (Number) order.

I tried changing the number of rows to display (from 8 to 20) *and the
column widths (to .5", 2") and nothing changes in the display! *Still
shows 8 rows, in number order.

It's like it's not taking my changes or it's getting its direction for
the combo box from somewhere else.

Any ideas? *Would a decompile be any help at all? *There's lots of
code in the app, but little in the form and nothing with this combo
box.

Thanks -
Sara

You've verified that the SQL that works (listed above) is the rowsource
for the combo?

If so, open up the code editor and press CTRL+F and look for
* * * * YourComboBoxName.Rowsource =
or
* * * * .Rowsource =
in the form's module.

Since you didn't write the app, it is possible that someone updates the
rowsource elsewhere. *If you find it, change it to reflect the right SQL
statement.

Bonafidehttp://www.youtube.com/watch?v=-6IKA0FRpnE- Hide quoted text -

- Show quoted text -
I looked for both txtOrigDepartment.Rowsource and Rowsource.
There is no ROWSOURCE in the entire project! I am baffled - any other
ideas?

Sara


Reply With Quote
  #5  
Old   
sara
 
Posts: n/a

Default Re: Combo Box based on Query sort not working - A2K - 02-27-2008 , 11:59 AM



On Feb 27, 12:48*pm, timmg <tmillsgronin... (AT) gmail (DOT) com> wrote:
Quote:
I assume that you're clicking on the rowsource button in the
properties window to edit the query, right?

Does the row source query change when you save and close the form and
then reopen it?

If you can change the rowsource to "SELECT Departments.DeptCode,
Departments.DeptName FROM Departments
*ORDER BY Departments.DeptName;" *but the next time you open the form
the order by clause is gone or different I'd look for an "On Open" or
"On Activate" event in the form that _may_ be resetting the
rowsource. *If the order by clause is there all of the time we've got
other problems.

A decompile probably wont help, but it couldn't hurt (as long as you
have a good backup).

hth,
tim mills-groninger

On Feb 27, 11:12*am, sara <saraqp... (AT) yahoo (DOT) com> wrote:





I have been asked to change a combo box display to sort in
alphabetical order. *This is in an app I did not write, but it should
be simple enough!
...

It is 2 columns, bound column 1, width 0,2".

Query: *SELECT Departments.DeptCode, Departments.DeptName
FROM Departments
ORDER BY Departments.DeptName;
...

Any ideas? *Would a decompile be any help at all? *There's lots of
code in the app, but little in the form and nothing with this combo
box.

Thanks -
Sara- Hide quoted text -

- Show quoted text -
Well, I guess "we've got other problems". Though I had tried to
change other values as well (column widths, rows to display) and they
all saved, I again put the SQL statement in the RowSoiurce and tried
it again.

Not working, and the Order By clause is still there. I don't see any
"Rowsource" in the form (or project) and I don't know what else could
change the combo box source.

I even opened the table on which the SQL is based and sorted it by
name. That seems to save (still sorted when I reopen the table), but
the combo box STILL doesn't sort by name. DeptCode is the primary key
to the table.

Any thoughts? It's just the "order by" that I need. I'll try
decompile now anyway.
Sara


Reply With Quote
  #6  
Old   
sara
 
Posts: n/a

Default Re: Combo Box based on Query sort not working - A2K - 02-27-2008 , 12:10 PM



On Feb 27, 12:48*pm, timmg <tmillsgronin... (AT) gmail (DOT) com> wrote:
Quote:
I assume that you're clicking on the rowsource button in the
properties window to edit the query, right?

Does the row source query change when you save and close the form and
then reopen it?

If you can change the rowsource to "SELECT Departments.DeptCode,
Departments.DeptName FROM Departments
*ORDER BY Departments.DeptName;" *but the next time you open the form
the order by clause is gone or different I'd look for an "On Open" or
"On Activate" event in the form that _may_ be resetting the
rowsource. *If the order by clause is there all of the time we've got
other problems.

A decompile probably wont help, but it couldn't hurt (as long as you
have a good backup).

hth,
tim mills-groninger

On Feb 27, 11:12*am, sara <saraqp... (AT) yahoo (DOT) com> wrote:





I have been asked to change a combo box display to sort in
alphabetical order. *This is in an app I did not write, but it should
be simple enough!
...

It is 2 columns, bound column 1, width 0,2".

Query: *SELECT Departments.DeptCode, Departments.DeptName
FROM Departments
ORDER BY Departments.DeptName;
...

Any ideas? *Would a decompile be any help at all? *There's lots of
code in the app, but little in the form and nothing with this combo
box.

Thanks -
Sara- Hide quoted text -

- Show quoted text -
As you suspected, Decomplie did nothing.
Sara


Reply With Quote
  #7  
Old   
timmg
 
Posts: n/a

Default Re: Combo Box based on Query sort not working - A2K - 02-27-2008 , 12:14 PM



If the decompile doesnt do anything try rebuilding the form.
Somethings starting with a fresh form and copying elements from the
suspect will fix some problems. On occassion I've had to rebuild
every control from scratch.

Rename the old form, create a new blank form with the correct name,
then start copying. If the new form has the same headers and footers
as the suspect you can select all and copy and paste..

Good luck.

tim mills-groninger

Quote:
Well, I guess "we've got other problems". * Though I had tried to
change other values as well (column widths, rows to display) and they
all saved, I again put the SQL statement in the RowSoiurce and tried
it again.

Not working, and the Order By clause is still there. *I don't see any
"Rowsource" in the form (or project) and I don't know what else could
change the combo box source.

I even opened the table on which the SQL is based and sorted it by
name. *That seems to save (still sorted when I reopen the table), but
the combo box STILL doesn't sort by name. DeptCode is the primary key
to the table.

Any thoughts? *It's just the "order by" that I need. * I'll try
decompile now anyway.
..



Reply With Quote
  #8  
Old   
Salad
 
Posts: n/a

Default Re: Combo Box based on Query sort not working - A2K - 02-27-2008 , 01:14 PM



sara wrote:

Quote:
On Feb 27, 12:48 pm, timmg <tmillsgronin... (AT) gmail (DOT) com> wrote:

I assume that you're clicking on the rowsource button in the
properties window to edit the query, right?

Does the row source query change when you save and close the form and
then reopen it?

If you can change the rowsource to "SELECT Departments.DeptCode,
Departments.DeptName FROM Departments
ORDER BY Departments.DeptName;" but the next time you open the form
the order by clause is gone or different I'd look for an "On Open" or
"On Activate" event in the form that _may_ be resetting the
rowsource. If the order by clause is there all of the time we've got
other problems.

A decompile probably wont help, but it couldn't hurt (as long as you
have a good backup).

hth,
tim mills-groninger

On Feb 27, 11:12 am, sara <saraqp... (AT) yahoo (DOT) com> wrote:






I have been asked to change a combo box display to sort in
alphabetical order. This is in an app I did not write, but it should
be simple enough!

...


It is 2 columns, bound column 1, width 0,2".

Query: SELECT Departments.DeptCode, Departments.DeptName
FROM Departments
ORDER BY Departments.DeptName;

...


Any ideas? Would a decompile be any help at all? There's lots of
code in the app, but little in the form and nothing with this combo
box.

Thanks -
Sara- Hide quoted text -

- Show quoted text -


As you suspected, Decomplie did nothing.
Sara
If I were you this is what I'd do. I'd create a query called
DepartmentsSorted. I'd open the form in design mode. I'd then click on
the combo box and press the Delete button. Poof. It's gone. Then I'd
click on the Combobox icon in the Toolbar and drag a new combo to the
form and follow the wizard to OZ using DepartmentsSorted as the
rowsource. I might give the ComboBox's name a differenct name just to
ensure that row source isn't reset elsewhere.

Then I'd save the form. Then see if it works.

If I wanted to play with the existing data instead of doing the above,
I'd start killing of a segment of code at a time, save the form, and
open it. First, delete the OnOpen, OnActivate, and OnLoad event code.
If that doesn't solve it, delete all AfterUpdate events. If that
doesn't do it, delete all BeforeUpdate events. If that doesn't work,
I'd delete all private/public functions and subs not associated with an
event. Then I'd delete all code. Sooner or later you'll remove the
code that's giving you problems.




Reply With Quote
  #9  
Old   
Dominic Vella
 
Posts: n/a

Default Re: Combo Box based on Query sort not working - A2K - 02-27-2008 , 03:38 PM



The Rowsource is found in the properties for the Combo Box, not the form.
It may be best to open the VB Editor for the form and search for "order".
That may be a clue to what's causing the rewrite.

Dom
"sara" <saraqpost (AT) yahoo (DOT) com> wrote

Quote:
Hi -

I have been asked to change a combo box display to sort in
alphabetical order. This is in an app I did not write, but it should
be simple enough!

The combo box is based on a table (and I've put in SQL and a query -
same problem)

It is 2 columns, bound column 1, width 0,2".

Query: SELECT Departments.DeptCode, Departments.DeptName
FROM Departments
ORDER BY Departments.DeptName;

When I run the SQL or the Query, stand-alone or from the properties
window, the sorting is correct (in Dept Name order).

The combo box still displays in DeptCode (Number) order.

I tried changing the number of rows to display (from 8 to 20) and the
column widths (to .5", 2") and nothing changes in the display! Still
shows 8 rows, in number order.

It's like it's not taking my changes or it's getting its direction for
the combo box from somewhere else.

Any ideas? Would a decompile be any help at all? There's lots of
code in the app, but little in the form and nothing with this combo
box.

Thanks -
Sara



Reply With Quote
  #10  
Old   
lyle fairfield
 
Posts: n/a

Default Re: Combo Box based on Query sort not working - A2K - 02-27-2008 , 03:56 PM



sara <saraqpost (AT) yahoo (DOT) com> wrote in
news:6430ce69-bff5-449e-ba5d-0ef6bd6238d5 (AT) 60g2000hsy (DOT) googlegroups.com:

Quote:
On Feb 27, 12:48*pm, timmg <tmillsgronin... (AT) gmail (DOT) com> wrote:
I assume that you're clicking on the rowsource button in the
properties window to edit the query, right?

Does the row source query change when you save and close the form and
then reopen it?

If you can change the rowsource to "SELECT Departments.DeptCode,
Departments.DeptName FROM Departments
*ORDER BY Departments.DeptName;" *but the next time you open the form
the order by clause is gone or different I'd look for an "On Open" or
"On Activate" event in the form that _may_ be resetting the
rowsource. *If the order by clause is there all of the time we've got
other problems.

A decompile probably wont help, but it couldn't hurt (as long as you
have a good backup).

hth,
tim mills-groninger

On Feb 27, 11:12*am, sara <saraqp... (AT) yahoo (DOT) com> wrote:





I have been asked to change a combo box display to sort in
alphabetical order. *This is in an app I did not write, but it
should be simple enough!
...

It is 2 columns, bound column 1, width 0,2".

Query: *SELECT Departments.DeptCode, Departments.DeptName
FROM Departments
ORDER BY Departments.DeptName;
...

Any ideas? *Would a decompile be any help at all? *There's lots of
code in the app, but little in the form and nothing with this combo
box.

Thanks -
Sara- Hide quoted text -

- Show quoted text -

As you suspected, Decomplie did nothing.
Sara
For openers I would:

A:

Make a copy of the form for safety.

Run this code:

SaveAsText acForm, "NameofForm", "NameofForm.txt"

LoadFromText acForm, "NameofForm", "NameofForm.txt"

Maybe the combobox will work now. If not then

B:

Find the file "NameofForm.txt". Open it in Notebook. Copy the text. Post
it here.

If we find the problem we'll tell you. If we don't it means the porblem
is somewhere else. We'll tell you how to look for that too.

or

C:

You will have found a bug in Access and be famous;

or

D:

Shut up, Lyle!


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.