Solved

Need code that does the same as hitting the F5 key

Posted on 2008-10-01
7
470 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

839 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