If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
how to feed result from P_T query to combo box?
I have this line of code working.
Form2 Form_load currentdb.QueryDefs("qryPassthrough").SQL = "Exec INV_getParentItemBYID " & Me.OpenArgs I also have a combo box (cboParentItem) on Form2 that ties to the qryPassthrough as its row source. How should I run the P_T, then tie the returned values to the combo? If I run DoCmd.OpenQuery ("qryPassthrough") cboParentItem.Requery The result will open in its own grid. With or without DoCmd, the combo would get data until the click event. Also, if the P_T did not return any thing, I want to do something like this: cboParentItem.RowSourceType = "Value List" cboParentItem.ColumnWidths = "2 in;0 in" cboParentItem.RowSource = "There is no parent info available" cboParentItem.DefaultValue = "There is no parent info available" how can I check the result of the P_T, then take action accordingly? Thanks! |
#2
|
|||
|
|||
The P-T query is a query so just set the Row Source type to Table/Query and
set the Row Source to "qryPassthrough". -- Duane Hookom MS Access MVP -- "homer" wrote in message ... I have this line of code working. Form2 Form_load currentdb.QueryDefs("qryPassthrough").SQL = "Exec INV_getParentItemBYID " & Me.OpenArgs I also have a combo box (cboParentItem) on Form2 that ties to the qryPassthrough as its row source. How should I run the P_T, then tie the returned values to the combo? If I run DoCmd.OpenQuery ("qryPassthrough") cboParentItem.Requery The result will open in its own grid. With or without DoCmd, the combo would get data until the click event. Also, if the P_T did not return any thing, I want to do something like this: cboParentItem.RowSourceType = "Value List" cboParentItem.ColumnWidths = "2 in;0 in" cboParentItem.RowSource = "There is no parent info available" cboParentItem.DefaultValue = "There is no parent info available" how can I check the result of the P_T, then take action accordingly? Thanks! |
#3
|
|||
|
|||
One note, homer ask to check first if there are any records returned from the
PT, and if not to set a value list -- I hope that helped Good luck "Duane Hookom" wrote: The P-T query is a query so just set the Row Source type to Table/Query and set the Row Source to "qryPassthrough". -- Duane Hookom MS Access MVP -- "homer" wrote in message ... I have this line of code working. Form2 Form_load currentdb.QueryDefs("qryPassthrough").SQL = "Exec INV_getParentItemBYID " & Me.OpenArgs I also have a combo box (cboParentItem) on Form2 that ties to the qryPassthrough as its row source. How should I run the P_T, then tie the returned values to the combo? If I run DoCmd.OpenQuery ("qryPassthrough") cboParentItem.Requery The result will open in its own grid. With or without DoCmd, the combo would get data until the click event. Also, if the P_T did not return any thing, I want to do something like this: cboParentItem.RowSourceType = "Value List" cboParentItem.ColumnWidths = "2 in;0 in" cboParentItem.RowSource = "There is no parent info available" cboParentItem.DefaultValue = "There is no parent info available" how can I check the result of the P_T, then take action accordingly? Thanks! |
#4
|
|||
|
|||
Try this
Dim MyRec as Recordset, MyDB as database Set MyDB=Codedb currentdb.QueryDefs("qryPassthrough").SQL = "Exec INV_getParentItemBYID " & Me.OpenArgs Set MyRec = MyDB.OpenRecordset ("qryPassthrough") If MyRec.eof then cboParentItem.RowSourceType = "Value List" cboParentItem.ColumnWidths = "2 in" cboParentItem.ColumnCount = 1 cboParentItem.RowSource = "There is no parent info available" cboParentItem.DefaultValue = "There is no parent info available" else cboParentItem.RowSourceType = "Table/Query" cboParentItem.ColumnWidths = "2 in;2 in" cboParentItem.ColumnCount = 2 Me.ComboBoxName.RowSource = "Select Field1, Field2 From qryPassthrough" end if Change the columncount, width, row source to suit your needs -- I hope that helped Good luck "homer" wrote: I have this line of code working. Form2 Form_load currentdb.QueryDefs("qryPassthrough").SQL = "Exec INV_getParentItemBYID " & Me.OpenArgs I also have a combo box (cboParentItem) on Form2 that ties to the qryPassthrough as its row source. How should I run the P_T, then tie the returned values to the combo? If I run DoCmd.OpenQuery ("qryPassthrough") cboParentItem.Requery The result will open in its own grid. With or without DoCmd, the combo would get data until the click event. Also, if the P_T did not return any thing, I want to do something like this: cboParentItem.RowSourceType = "Value List" cboParentItem.ColumnWidths = "2 in;0 in" cboParentItem.RowSource = "There is no parent info available" cboParentItem.DefaultValue = "There is no parent info available" how can I check the result of the P_T, then take action accordingly? Thanks! |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
EXCEL:NUMBER TO GREEK WORDS | vag | Worksheet Functions | 1 | June 15th, 2005 05:57 PM |
query bound to combo box doesn't sort correctly | epigram | Running & Setting Up Queries | 3 | May 14th, 2005 02:18 PM |
Design help, please | SillySally | Using Forms | 27 | March 6th, 2005 04:11 AM |
Conversion | SVC | Worksheet Functions | 9 | February 28th, 2005 02:29 PM |
Here's a shocker | Mike Labosh | General Discussion | 2 | October 26th, 2004 05:04 PM |