Solved

I need your help to ammend this code

Posted on 2002-07-22
4
149 Views
Last Modified: 2010-05-02
Hi,

Please read the following code:

Private Sub Command1_Click()
Dim CLA as string

Me.Combo1.Visible = True
ClA = Me.Combo1.Text
Me.Adodc1.Recordset.Filter = "Code = '" & ClA & "'"

'
'
End Sub

in form load: Combo1.Visible = False

my problem is: by clicking Command1, combo1 becomes visible true , but VB go directly to the next line of the code without waiting to select a value from combo1 to put in CLA as shown above...

I need your help to show me how to make combo1 stop and WAIT until i select a value then complete the code ...

Thanks
Ray
0
Comment
Question by:ray14
  • 2
4 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 7170590
1. Add a refresh:

Me.Combo1.Visible = True
Combo1.refresh
Combo1.setfocus

then harvest the value from Combo1_LostFocus()
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 75 total points
ID: 7170617
Welcome to event driven programming, ray14.  Your problem is that you are trying to do too much in the click event of the button.  You could use the Combo click event to trap the result from the combobox instead:

Private Sub Command1_Click()
Dim CLA as string

Me.Combo1.Visible = True

'
'
End Sub

Private Sub Combo1_Click()
  Dim CLA as string

  ClA = Me.Combo1.Text
  Me.Adodc1.Recordset.Filter = "Code = '" & ClA & "'"

End Sub

If you allow people to type in the combo box, you might want to trap the Change event as well.
0
 

Author Comment

by:ray14
ID: 7170629
Hi Cookre,

Thank you for replying. But I still have the same problem. may you give me more help !!!

ray
0
 

Author Comment

by:ray14
ID: 7170664
Hi PaulHews,

thank you for your excellent help and expert note

Ray14
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 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

26 Experts available now in Live!

Get 1:1 Help Now