By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,506 Members | 2,282 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,506 IT Pros & Developers. It's quick & easy.

Query Grid Criteria based on a Form - Syntax

Walt in Decatur
P: 20
I have a form which is tied to a table with data for equipment belonging in a particular space (tbl_equpment_data). 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_pane
Form that displays general data: subfrm_General_tab
Form that displays just the basic equipment data is: subfrm_equipment_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_data 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_data_delete It is based on tbl_equipment_data

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

[Forms]![_frm_big_space_list_tab]![subfrm_main_pane].[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_pane].[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_equipment_form_general_data.Visible = True
Else
Me.subfrm_equipment_form_general_data.Visible = False
DoCmd.OpenQuery "qry_equipment_data_delete", acViewNormal, acEdit
DoCmd.RunCommand acCmdRun
DoCmd.Close acQuery, "qry_equipment_data_delete", acSaveYes
End If
End Sub

Any help will be appreciated.
Nov 19 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.