473,394 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Using If statements to check if buttons have been clicked

I am new to VBA

Please can someone help get me started.

I need to know how to use an if statement to check if a button has been
pressed i.e. if button 1 is pressed a file will be imported from a
particular location if button 2 is pressed a file will be imported from
a different location.

I have several buttons but figure if someone can get me to this point I
should be able to repeat the process.

Thanks in advance for any help anyone can give me.

May 3 '06 #1
3 4127
DFS
Andrew wrote:
I am new to VBA

Please can someone help get me started.

I need to know how to use an if statement to check if a button has
been pressed i.e. if button 1 is pressed a file will be imported from
a particular location if button 2 is pressed a file will be imported
from a different location.

I have several buttons but figure if someone can get me to this point
I should be able to repeat the process.

Thanks in advance for any help anyone can give me.


You could use an option group and option buttons, and let the user choose
which they want. Each option button will assign a value (starting with 1)
to the option group. Your code will check the value of the option group and
import the file from the correct location. Assume the option group is named
'frameImport' with 3 radio buttons, your code might be like this:

If Me.frameImport = 1 then
'import from location
elseif me.frameImport = 2 then
'import from a different location
else if me.frameImport = 3 then
'import from a different location
Endif

Or you could put a listbox on screen, and set the RowsourceType to 'Value
List', set the RowSource to the file import locations, and then your import
code might be something like:

DoCmd.TransferText blah blah me.listFileLocation blah blah

May 3 '06 #2
"Andrew" <ah****@talktalk.net> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
I am new to VBA

Please can someone help get me started.

I need to know how to use an if statement to check if a button has been
pressed i.e. if button 1 is pressed a file will be imported from a
particular location if button 2 is pressed a file will be imported from
a different location.

I have several buttons but figure if someone can get me to this point I
should be able to repeat the process.

Thanks in advance for any help anyone can give me.


If you "press" a button then the "on click" event will fire, you don't need
any "if" statements, you just include what you want to happen in the event
procedure.

HTH - Keith.
www.keithwilby.com
May 3 '06 #3
check out the help file for the OnClick Event

*** Sent via Developersdex http://www.developersdex.com ***
May 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there...
2
by: Ben | last post by:
My current project requires me to create part of a form that is created on the fly. The project consists a list of entries to an event. The name and address and such is easy. The design is detup so...
6
by: Robert | last post by:
Hello. I have been trying out the Lebans ToolTip Classes at http://www.lebans.com/tooltip.htm, to display "balloon" style help tips in a form. The classes I am using are located at...
7
by: Shaldaman | last post by:
Hi Is there a property in MS Access for the following: 1) For a Command Button on a form, is there a property that can be used to determine if it has been clicked? eg: Me!button7.Clicked - I...
4
by: Shawn | last post by:
Hi. I have a ToolBar with a couple of ToolBarButtons. On postback after clicking on of the buttons Page_Load is called first then the ToolBarButton's click event is called. Is there anyway for...
5
by: mayur_hirpara | last post by:
Hi, I have been developing web applications for a while now. However, as I was thinking through the architecture I really don't understand the "How server can identify between which buttons has...
1
by: JHawk24821 | last post by:
I am building a simple card matching game where the user picks two buttons on a form out of a group of buttons in an attempt to find a match. I have already taken care of the randomization needed...
11
by: dana1 | last post by:
I have a form which contains some buttons. The buttons use some of the standard images that come with access 2003 (e.g., the move next record image, or the sort ascending/descending images). The...
25
by: samjnaa | last post by:
Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword "with" which allows an object- name to be declared as governing the following statements. For...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.