Query Grid Criteria based on a Form - Syntax

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Walt in Decatur
    New Member
    • Jun 2007
    • 20

    Query Grid Criteria based on a Form - Syntax

    I have a form which is tied to a table with data for equipment belonging in a particular space (tbl_equpment_d ata). This form is actually a subform on a main form which also deals with other data for the list of spaces.

    Structure:
    Main Form: _frm_big_space_ list_tab
    Container Subform: subfrm_main_pan e
    Form that displays general data: subfrm_General_ tab
    Form that displays just the basic equipment data is: subfrm_equipmen t_form_general_ data It is displayed in the datasheet view. On this form I have a checkbox which allows the datasheet to be visible after update or not visible when the box is unchecked. This works fine. I also wrote VBA code that invokes a delete query so that when the box is unchecked, all the records in the underlying tbl_equipment_d ata for that space will be deleted.

    In the criteria grid of delete query design I want to limit the records to be deleted to the ones specific for the currently selected space.

    Delete query is called: qry_equipment_d ata_delete It is based on tbl_equipment_d ata

    Here's what I have as criteria in the {Room Name] field of the query:

    [Forms]![_frm_big_space_ list_tab]![subfrm_main_pan e].[subfrm_General_ tab].[Room Name]

    When the query is run (the VBA code is in the afterupdate event of the checkbox on the form), I get the dreaded "Enter Parameter Value" box and the whole thing craps out. So I think my syntax for WHERE clause is wrong. Currently it reads:

    WHERE (((tbl_general_ data.[Room Name])=[Forms]![_frm_big_space_ list_tab]![subfrm_main_pan e].[subfrm_General_ tab].[Room Name]));

    Here's the VBA code I'm using, it probably needs help too... :-(

    Private Sub Equipment_Check _AfterUpdate()
    If Equipment_Check .Value = True Then
    Me.subfrm_equip ment_form_gener al_data.Visible = True
    Else
    Me.subfrm_equip ment_form_gener al_data.Visible = False
    DoCmd.OpenQuery "qry_equipment_ data_delete", acViewNormal, acEdit
    DoCmd.RunComman d acCmdRun
    DoCmd.Close acQuery, "qry_equipment_ data_delete", acSaveYes
    End If
    End Sub

    Any help will be appreciated.
Working...