Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a VB Form in Access 2

Status
Not open for further replies.

drmichaelw

IS-IT--Management
Oct 5, 2002
66
0
0
US
I have vb code in my access program and would like to create a form with input boxes and a button. I want the button to run my code. The problem is I can't get the toolbox icon to be active so I can click it to get my form tools. Any suggestions?
 
Hi

Can you see the database window?

If not try pressing F11

When you can see DB Window, choose Forms, then do New

If you cannot see DB Window with F11, it may have been disabled in code.. post back Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I see the project and properties window on the left. I'm not seeing the database window or I just don't know here to look.
MW
 
Hi

You are in the VBA code window, you need to be in the Access window to see the database window and create a form Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Okay,
I thought I was created a VB form in VB.

Yes, yes I can see the database window.

Would I then create a normal access form to run the vb code?
and can I link a button to run the or call my procedure?
MW
 
Hi

We are getting confused here:

There is a free standing product Visual Basic, commonly called VB

There is another Product called Access which is a database management system with Application development tools including Forms, reports, queries, and VBA (Visual Basic For Applications)

Which product(s) are you talking about? Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Sorry,

I am using Access. I have written vba code in Access.
I would like to know how I can run this code from a form in this database.

I created a form, and put a button on it.
I am trying to figure out how to run the vba code when I click that button.

When I created the button I had a number of options, which one if any do I choose to run the vba code?
MW
 
With the form in design mode, open the properties window, on the EVENT tab under ON CLICK choose Event Procedure. This should create you an on click procedure in the vba code section, once this is done just cut and paste the procedure you wish the button to do into the SUB procedure.
 
In design view I clicked on the button and in properties window clicked EVENT and ON CLICK. However, I did not see the click procedure in my module?
MW
 
Ok,
When you click inside the On Click event, you will see a small command button with three dots (...). Click on that, then select Code Builder. That will drop you into "Private Sub cmdYourName_Click()" procedure. You can now enter VBA code. HTH, [pc2]
Randy Smith
California Teachers Association
 
Hi

OK, I would have thought you have found the on click event now.

You say "I am using Access. I have written vba code in Access ", is this code a Function or a Subroutine? ie does it begin with:

Sub MySub()

or

Function MyFunction()

where MySub and MyFunction are your names

If it is a sub, you run it in the OnClick ebvent by simply typing the name of the sub, eg

MySub

If it is a function you need a variable to assign the return value to eg:

Dim X
x= MyFunction()

to do things correctly / efficiently, you should have assigned a type to the function, and a (similar) type to X, eg somthing like

Dim X as Integer

are you running now?
Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Got it, Its easy once you know the way

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top