Now there is an easy solution that will allow you to switch between IDE and AHCI in the bios and Windows will boot without any problems. The key is to enable the AHCI driver in Windows before you make the setting change in the BIOS.
For most users this will work:
1. Open Registry Editor and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\msahci.
2. Right click on the Start registry DWORD and select Modify.

3. Set the value to 0 and click OK.

4. Now the Start setting should be set to 0.

5. Reboot and enable the AHCI setting in your BIOS.
If you are using a RAID adapter or other interface try the following:
A. Open up Registry Editor and naviage to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\iaStorV OR HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\iaStor.
B. Repeat the steps above.