Default in a textbox and change a module name

G

Guest

2 questions:
1)
I have a form that ask the user for the bill number (a 10 numbers
number),and the user needs to type all the numbers each time that a bill is
done, so I want to use a default value in the textbox1 linked to the last
value (that is saved in a cell c5) + 1, (in cell c1 appears 0889888881 so in
the textbox appears 0889888882)
Pd. I know that this can be done automatically, but because there is some
time that bills are cancelled I need to ask the user for the bill number.
Pd2. I know that default value is an option on inputbox property, but I
cant use inputbox because my form has a lot of buttons¡¡¡¡¡¡

2)
There is some way to change the module names (instead of module1 say
easyprgms1) and also to lookup for a specific sub (because I have 100 subs
and each time I need to modify something I need to check in each of the 15
modules that I have)

Tanks for your Help
 
T

Tom Ogilvy

Do you have a list of Bill Numbers

to reduce errors, why not use a combobox and let the user select the Bill
number.

otherwise

Private Sub Userform_Activate()
Textbox1.Text = format(Worksheets("Sheet1") _
.Range("C5") + 1,"0000000000")
End Sub


In the project explorer, select the module and look in the properties window
(F4 if it isn't visible) Replace ModuleX with the name you want. (Name is
the only property)
 
G

Guest

thaknd tom, I have another question, what is an event?, I found this term in
tge class chapter of my "VB for Dummies book"¡¡¡¡¡

TIA
 
T

Tom Ogilvy

In writing the code for Excel, the authors have defined certain "Events".
This is code that will call code you design and tie to this event. For
example, manually editing a cell in Excel triggers a call to the
worksheet_Change event. If I put code in that event declaration or put a
call to one of my macros in the event declaration, whenever a cell is
edited, the event will be executed and my code will in turn be executed.

See Chip Pearson's page on Events
http://www.cpearson.com/excel/events.htm

The Activate event for a userform is fired whenever the userform is
activated.

If you go into the Userform code module, in the left dropdown select
Userform and in the right dropdown (at the top of the module), select
Activate.
 
B

Bob Phillips

An event is something that happens. Modern languages allow you to monitor
and act upon events.

For instance, opening a workbook is an event. VBA allows code to be written
that is triggered by that event, and allows the developer to take action
based upon that workbook opening.

Other such events are a worksheet being activated, a cell being selected, a
cell being changed.

In your book, being VB, it probably won't cover Excel events, but should
cover form control events. Forms will have controls, such as checkboxes,
textboxes, command buttons. They would be useless until you were able to
code based upon something happening to them, so many events for the controls
are exposed, such as the click event, change event, etc.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top