Link to home
Start Free TrialLog in
Avatar of PatKung
PatKungFlag for United States of America

asked on

Need code that does the same as hitting the F5 key

Could someone give me what the code should be to do the same thing as hitting F5 and the event to put it in.  I have two text boxes on my form. The first one I choose what FY I want, the next drop down should limit my choices based on the FY I choose but it doesn't unless I hit F5.

Thanks, Pat
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

do you mean you have two combo boxes and you want to filter the second based on the selection from the first combo..

set the row source of the combo in the after update event of the the first combo

private sub combo1_afterupdate()

me.combo2.rowsource="select fieldName from tablex where [FY]= " & me.combo1

end sub

if [FY] is text data type use this

me.combo2.rowsource="select fieldName from tablex where [FY]= '" & me.combo1 &"'"
Avatar of PatKung

ASKER

That didn't work.  
Here is what I had on the Row Source for the second Combo:
SELECT DISTINCT tbl_05_TypeInvoice.strTypeInv FROM tbl_05_TypeInvoice INNER JOIN tbl_01_Main ON tbl_05_TypeInvoice.strTypeInv=tbl_01_Main.strTypeInv WHERE (((tbl_01_Main.intFY)=Forms!frm_05_InvoiceGen!txtChooseFY)) ORDER BY tbl_05_TypeInvoice.strTypeInv;

I removed it and put on the first Combo in the afterupdate:
Private Sub txtChooseFY_AfterUpdate()
Me.txtTypeInv.RowSource = "select intFY from tbl_01_Main where [intFY]= " & Me.txtChooseFY
End Sub

Chose 2007 on the first Combo, the second one gave me a string of 2007.  What I should have gotten was the five different types of invoices that exist with a FY of 2007.

Did I do something different than you said?

Thanks, Pat
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PatKung

ASKER

That worked, but is there any code that just does what the F5 does that I could use when needed?  
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PatKung

ASKER

That worked perfect!  And a lot less code.  Still did it on the AfterUpdate of the previous ComboBox.  

Thanks, Pat
Avatar of PatKung

ASKER

Thanks again!!