forms
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Forms

Forms

resolvedResolved · Medium Priority · Version 2010

replyReply Wed 1 Feb 2012, 12:36Delegate Ross said...

Ross has attended:
Excel VBA Intro Intermediate course

Forms

I have created a form

Sub Selectionlist()

Account.AddItem "Net Income1"
Account.AddItem "cash1"
Account.AddItem "Net Income1"
Account.AddItem "Depreciation & Amortisation"
Account.AddItem "Intercompany Interest"
Account.AddItem "Minority interest"
End Sub

Then i have addeded a command button

what i would like to do is

once they have selected one of the items in the drop down on fhe form do a function. say

if "selections list above" = "Net Income1" then
Range("a1:b2").select.
End If


The problem i have is cant get the macro to refer to the form. I need to name the selection in the form somehow?

Also how would the command button know what macro to run(will it just run the routine sitting behind the form? if that the case i guess i could call other macros into the routine?)

For upcoming training course dates see: Pricing & availability

replyReply Fri 3 Feb 2012, 11:48Trainer Simon said...

RE: Forms

Hi Ross,

Thank you for your question.

The value you talk about are they displayed in Text Boxes or a combo box? If so, name the text boxes and combo box in the properties in the VBA window.

Double click into the form VBA and create a new routine. The code would be something like this:

e.g. cboTest is the name of the combo box


Private Sub cboTest_change()

Select Case Me.cboTest

Case Is = "T1"
Sheets("Sheet1").Range("a1:a5").Select

Case Is = "T2"
Sheets("Sheet1").Range("b1:b5").Select

Case Is = "T3"
Sheets("Sheet1").Range("c1:c5").Select

Case Else

Sheets("Sheet1").Range("d1:d5").Select

End Select

End sub

Add a Command button to sheet1 and right click view code. In the command button procedure type the name of the form followed by .show

e.g. MyForm.show

I hope this helps.

Regards

Simon

Fri 10 Feb 2012: Automatically marked as resolved.

 

Please browse our web site to find out more about
access advanced courses and other Microsoft training courses.

Access tip:

Changing MS Programs Text Size

A handy way to increase or decrease the size of text in Microsoft Word, Microsoft PowerPoint, Microsoft FrontPage, or Microsoft Publisher, first, select the text you want to resize.

Then, to increase the font size, press CTRL+SHIFT+>.

To decrease the font size, press CTRL+SHIFT+<.

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard