0

Hi,

I am using VB 2008 Express to connect to an Access 2007 database.

I have a combo box named cboYEARMONTH that is populated by the database. I have this part working great.

When the user selects a YEARMONTH with the combo box I want the SelectedIndexChanged event to initiate a query in my database called ExactReprints_Query and limit the results to the YEARMONTH selected in the combo box. The results will then be output to a text box called TxtExactReprints.

Can anyone please help me figure out how to code this part?

Thanks in advance,
Diana

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Netcode
0

sub cmbYearMonth_SelectedIndexChanged(byval sender as object, byval e as eventargs) handles cmbyearmonth.selectedindexchanged

dim conn as new sqlconnection("?")
dim com as new sqlcommand
dim reader as sqldatareader

com.connection = conn
com.comandtype = storedprocedure
com.commandtext = "ExactReprints_Query"

com.parameters.addwithvalue("@YearMonth", cmbYearMonth.selecteditem) 'or what ever else your parameter is

txtExactReprints.clear

try
con.open

reader = com.executereader
do while reader.read
txtExactReprints.text &= reader.item("?") & vbtab
end while

catch

finally
conn.dispose
com.dispose
if reader isnot nothing then reader.dispose
end try

end sub

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.