How do I use hook_views_query_alter()?
Right. In order to "do" anything with views in a module, you have to implement hook_views_api. Without this, your module won't be recognised by Views, at all, ever (AFAIK).

Please add the following to your module code:

/**
 * Implementation of hook_views_api().
 */
function alterform_views_api() { // your module name into hook_views_api
  return array(
    'api' =&gt; 2,
    // might not need the line below, but in any case, the last arg is the name of your module
    'path' =&gt; drupal_get_path('module', 'alterform'),
  );
}


This should fix it so your module is at least recognised, then you can start debugging it :)

A good way to start debugging a view (i.e. a baby step) is to put dpm($view); right at the start of the views function you're implementing. In most cases, that will dump info onto the screen that will help you see where you're at. Would suggest doing this with devel.module installed/switched on.

Edit: This assumes Views 2 and Drupal 6. You'd best ask around if those aren't your weapons of choice.