Solved

Need code that does the same as hitting the F5 key

Posted on 2008-10-01
7
467 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

895 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

21 Experts available now in Live!

Get 1:1 Help Now