Possible food allergy to shrimp once after years of eating it. Can I have crab?

Need further testing. Both shrimp and crab are considered shellfish. You can be allergic to only one or both but should be tested by an allergist to be certain. Commonly restaurants do not keep their shellfish separate so need to also be careful with cross-contamination.
Proceed with caution. First i would verify the food allergy. I recommend avoidance until fully evaluated and tested by a board certified allergist. If you are allergic to shrimp, i usually recommend avoiding all crustaceans (shrimp, lobster, crab etc) but i would recommend being tested to all of these as they frequently cross react.
Probably not. The following crustaceans could cause cross reactions: shrimp, lobster, crab, prawns. If you have an allergy to one of these you may react to any of the others. See an allergist for skin testing to know for sure.