dishwater not always filling with water

The dishwasher was not filling. I repaced the float and switch. It worked fine. Since then, it has worked and then not worked. Any suggestions?

Recheck the float install to be sure that it operates freely.
Could be a piece of food has lodged in the mechanism and it is sticking.

Leave the kick plate off so the next time it happens you can check to see if the float switch is activated.

Next would be either a sticking water valve or a bad connection from the control to the float/water valve.