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