Solved

I need your help to ammend this code

Posted on 2002-07-22
4
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

695 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