Solved

Need code that does the same as hitting the F5 key

Posted on 2008-10-01
7
462 Views
Last Modified: 2013-11-28
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
0
Comment
Question by:PatKung
  • 4
  • 3
7 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 22616809
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 &"'"
0
 

Author Comment

by:PatKung
ID: 22617027
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
0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 500 total points
ID: 22617156

try this

Private Sub txtChooseFY_AfterUpdate()
dim sql
sql="SELECT DISTINCT tbl_05_TypeInvoice.strTypeInv"
sql=sql & " FROM tbl_05_TypeInvoice INNER JOIN tbl_01_Main"
sql=sql & " ON tbl_05_TypeInvoice.strTypeInv=tbl_01_Main.strTypeInv"
sql=sql & " WHERE tbl_01_Main.intFY=" & me.txtChooseFY & "
sql=sql & " ORDER BY tbl_05_TypeInvoice.strTypeInv"

Me.txtTypeInv.RowSource = sql
End Sub
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:PatKung
ID: 22617216
That worked, but is there any code that just does what the F5 does that I could use when needed?  
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 22617256
try

Me.txtTypeInv.requery
0
 

Author Comment

by:PatKung
ID: 22617307
That worked perfect!  And a lot less code.  Still did it on the AfterUpdate of the previous ComboBox.  

Thanks, Pat
0
 

Author Closing Comment

by:PatKung
ID: 31502063
Thanks again!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now