I should see what code you used to crash (maybe you tried to set texture on the model material when no material was assigned to it?), however the code to change the texture of a material at runtime:
// .. engine initialize functions
TModel box = LoadModel("abstract::oildrum.gmf");
TMaterial mat = LoadMaterial("abstract::cobblestones.mat");
PaintEntity(box, mat, 1);
while(!KeyHit(KEY_ESCAPE) && !AppTerminate())
{
if (KeyHit(KEY_I))
SetMaterialTexture(mat, LoadTexture("abstract::road_dashedwhite2.dds"), 0);
else if (KeyHit(KEY_V))
SetMaterialTexture(mat, LoadTexture("abstract::cobblestones.dds"), 0);
UpdateFramework();
RenderFramework();
Flip();
}
return Terminate();