By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,490 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,490 IT Pros & Developers. It's quick & easy.

Using If statements to check if buttons have been clicked

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
"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

P: n/a
check out the help file for the OnClick Event

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

This discussion thread is closed

Replies have been disabled for this discussion.