Solved

VBA: User form in Excel

Posted on 2002-03-28
5
225 Views
Last Modified: 2008-03-10
Hi everyone,
What I have created, using VBA in Excel, is a custom user form for customer payments input.
The form has 3 fields for specifying the customer number, the customer name and the amount paid.
The customer name is linked to a database in the same Excel s/sheet containing all customer numbers and names.
On the form I have a button and when pressed, I have a macro that runs and picks up the customer name by looking at the database until it finds the customer number and picks up the name - the cell on the right.  The macro works, but I want to know if there is a way to do this without pressing this button.
Can I get the macro to run or use another method so that the customer name can be displayed automatically once the customer is entered.
I am hoping this is pretty simple, but please help.
I can not think of a way and it does get annoying to always go through an extra step in order to verify the customer name.
Help!
0
Comment
Question by:vbAngel
[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
  • 3
  • 2
5 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 6902198
put it under the on leave method of the textbox? or another method of the textbox, lost focus?

why do you want to do that anyway, it can be a bit cumbersome if you key in a wrong name and leave the box the program tries to look it up...

:O)Bruintje
0
 

Author Comment

by:vbAngel
ID: 6902232
"leave method of the textbox" or "lost focus" - what are those and how could I use them?
Are they available in VBA?

I need for the keyer to varify the customer name as the payment can be easily keyed to a wrong customer.  I want to display it tough, so the keyer can just look up, make sure the name is right and keep on keying other payments.
Thanks,
vb
0
 
LVL 44

Accepted Solution

by:
bruintje earned 75 total points
ID: 6902253
Hi vbAngel,

here are 4 possible candidates to get the check handled by an eventhandler of the textbox

Private Sub TextBox1_AfterUpdate()
  MsgBox "afterupdate"
End Sub

Private Sub TextBox1_Change()
  MsgBox "change"
End Sub

Private Sub TextBox1_Enter()
  MsgBox "enter"
End Sub

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
  MsgBox "exit"
End Sub

I guess the on enter, change, are not suitable leaves

afterupdate which is triggered by tab or leaving the cell

exit which is triggered by enter but you can set the focus back on the box like

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
  MsgBox "exit"
  TextBox1.SetFocus
End Sub

HTH:O)Bruintje
0
 

Author Comment

by:vbAngel
ID: 6903709
Thanks Bruintje,
this is exactly what I wanted.
Simple yet effective.
Thanks again,
vb
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6904338
glad it helped
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
passing a value with stream reader AFTER a ";" 3 84
Copy a row 12 70
VB6 - Convert HH:MM into Decimal 8 70
VBA - If Bookmark = "XXBOOKMARKXX" then 15 51
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

726 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