Solved

I need your help to ammend this code

Posted on 2002-07-22
4
150 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

809 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