Solved

I need your help to ammend this code

Posted on 2002-07-22
4
148 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi PaulHews,

thank you for your excellent help and expert note

Ray14
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

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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now