|
Subject:
|
Query based on combo box selection help
|
|
Posted By:
|
Elain
|
Post Date:
|
12/30/2005 11:00:17 AM
|
I have a form with three subforms, and I'm having problem with one of them. The link between subforms and forms are store number, which is stored in a combo box. Idealy, after a user pick a store from the combo box, the subform would update itself. Two out of the three subforms are based on two crosstab queries and they work perfectly fine. The last subform is a select query, and it seems like it's not rerunning itself after updating the combo box. The query is very simple, it just has store number, description, and grouped by amount. I tried with no criteria in the store field and run the masterform,seems like all it's doing is showing value for the first store in the table, and never changes afterwards, I also tried entering "forms!frmStores!cmbStore" in the criteria for the store, then the subform came out empty, it seems like it's only reading combo box's default value null. I have a line of code for the mater form frmStores as "me.[DisplaySubform].requery" for all three subforms, but it seems like it's working for the first two and not the select query. Anybody can help me with this? oh, the combo box is unbounded, because i do not want my table to be updated by selection. Please help. Thank you!
|
|
Reply By:
|
twalter
|
Reply Date:
|
1/3/2006 10:33:34 PM
|
Not sure if this is will do the trick but it works for me with one subform. On the combo box I have 2 event procedures (maybe there's a way to do it all as one??) the first is triggered on After Update the other is Not In List.
Private Sub cboSearchByStoreID_AfterUpdate()
On Error GoTo Err_cboSearchByStoreID_AfterUpdate
Dim rst As DAO.Recordset Set rst = Me.RecordsetClone rst.FindFirst "[StoreID] = " & Str(Me![cboSearchByStoreID]) Me.Bookmark = rst.Bookmark Me![cboSearchByStoreID] = Null
Exit_cboSearchByStoreID_AfterUpdate: Exit Sub
Err_cboSearchByStoreID_AfterUpdate: Resume Exit_cboSearchByStoreID_AfterUpdate
End Sub
Private Sub cboSearchByStoreId_NotInList(NewData As String, Response As Integer)
MsgTitle = "Store ID Not Found" NewEntry = MsgBox("The store ID you selected was not found.", MsgDialog, MsgTitle)
End Sub
Good luck!!
|
|