G
Guest
For my Microsoft Access Database I have have a Customer form which allows me
to add and edit Customer details. The Customer Table contains a 'Customer ID'
field (The Primary Key), First Name, Last Name and Business Name (There are
others but these are the only ones used for the search combo box). Previously
for the customer form, I set the Search Combo box (which looks up a record
and display it) Row Source to allow the User to type in the First Name and
then Last Name with a space between. This worked great but didn't allows me
to search by Surname if I didn't know the first name or allow me to search by
business name.
Recently I just Purchased Microsoft Access 2007 (My database was built
originally in Microsoft Access 2000 Format, Upgraded to Microsoft Access
2002/2003 format 6 months ago) and I upgraded my database to the new
Microsoft Access 2007 format. As far as I could see the database was working
100% fine and so I decided to do a lot of upgrading to forms and try out some
new things. So when I found out how to use UNION Query Statements I thought I
should use them in my Customer Form. When I opened up my database to edit the
Combo Box I held down the shift key to bring up the navigation bar (I have
setup my database not to show the navigation bar when opening up the database
normally) and I edited the row source.
After some trial and error I was able to get the combo box to work exactly
the way I wanted it. If I selected a customer by First Name and then Last
Name the record would show and the same occured with last name,first name and
business name. I tested this quite a few times and it indeed worked. the next
day I opened up the database (This time without the shift key as I needed
only to edit customer details) and attempted to lookup the customer. When I
selected the customer from the combo box the form would not go to the record
and would remain blank.
Immediately I assumed I must have made a mistake editing the night before so
I closed down the database and started it up by holding the shift key. After
briefly looking at the SQL Query Statement for the Combo Boxes row source
(and not editing the code) I opened the form to test it and it worked. I then
closed the database down and opened it up (without holding the shift key) and
it didn't work. I then closed it down holding the shift key this time and it
did work. Since then I have tested this numerous times and can conclude that
the Customer Form will only lookup customers if I open the database holding
the shift key. I then assumed this may have something to do with the
navigation bar, so I set the navigation bar to always be on in the Access
Options. This still didn't help.
This to me would appear to be more of a Microsoft Access 2007 bug than a
mistake I have made since opening forms up to test in the editing mode (by
holding down the shift key when the Microsoft Access Database is opened)
should work the same if I opened it up not in editing mode. The code that I
use for the Search Combo Box is as follows:
SELECT Customers.ID, [Customers].[First Name] & " " & [Customers].[Last
Name] AS Expr1 FROM Customers; UNION ALL SELECT Customers.ID,
[Customers].[Last Name] & " " & [Customers].[First Name] FROM Customers;
UNION ALL SELECT Customers.ID, [Customers].[Business Name] FROM Customers;
to add and edit Customer details. The Customer Table contains a 'Customer ID'
field (The Primary Key), First Name, Last Name and Business Name (There are
others but these are the only ones used for the search combo box). Previously
for the customer form, I set the Search Combo box (which looks up a record
and display it) Row Source to allow the User to type in the First Name and
then Last Name with a space between. This worked great but didn't allows me
to search by Surname if I didn't know the first name or allow me to search by
business name.
Recently I just Purchased Microsoft Access 2007 (My database was built
originally in Microsoft Access 2000 Format, Upgraded to Microsoft Access
2002/2003 format 6 months ago) and I upgraded my database to the new
Microsoft Access 2007 format. As far as I could see the database was working
100% fine and so I decided to do a lot of upgrading to forms and try out some
new things. So when I found out how to use UNION Query Statements I thought I
should use them in my Customer Form. When I opened up my database to edit the
Combo Box I held down the shift key to bring up the navigation bar (I have
setup my database not to show the navigation bar when opening up the database
normally) and I edited the row source.
After some trial and error I was able to get the combo box to work exactly
the way I wanted it. If I selected a customer by First Name and then Last
Name the record would show and the same occured with last name,first name and
business name. I tested this quite a few times and it indeed worked. the next
day I opened up the database (This time without the shift key as I needed
only to edit customer details) and attempted to lookup the customer. When I
selected the customer from the combo box the form would not go to the record
and would remain blank.
Immediately I assumed I must have made a mistake editing the night before so
I closed down the database and started it up by holding the shift key. After
briefly looking at the SQL Query Statement for the Combo Boxes row source
(and not editing the code) I opened the form to test it and it worked. I then
closed the database down and opened it up (without holding the shift key) and
it didn't work. I then closed it down holding the shift key this time and it
did work. Since then I have tested this numerous times and can conclude that
the Customer Form will only lookup customers if I open the database holding
the shift key. I then assumed this may have something to do with the
navigation bar, so I set the navigation bar to always be on in the Access
Options. This still didn't help.
This to me would appear to be more of a Microsoft Access 2007 bug than a
mistake I have made since opening forms up to test in the editing mode (by
holding down the shift key when the Microsoft Access Database is opened)
should work the same if I opened it up not in editing mode. The code that I
use for the Search Combo Box is as follows:
SELECT Customers.ID, [Customers].[First Name] & " " & [Customers].[Last
Name] AS Expr1 FROM Customers; UNION ALL SELECT Customers.ID,
[Customers].[Last Name] & " " & [Customers].[First Name] FROM Customers;
UNION ALL SELECT Customers.ID, [Customers].[Business Name] FROM Customers;