A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

how to feed result from P_T query to combo box?



 
 
Thread Tools Display Modes
  #1  
Old September 13th, 2005, 06:11 PM
homer
external usenet poster
 
Posts: n/a
Default 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  
Old September 13th, 2005, 07:30 PM
Duane Hookom
external usenet poster
 
Posts: n/a
Default

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  
Old September 13th, 2005, 10:32 PM
Ofer
external usenet poster
 
Posts: n/a
Default

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  
Old September 13th, 2005, 10:34 PM
Ofer
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 06:31 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.