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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing File 1

Status
Not open for further replies.

lars7

Technical User
Aug 16, 2005
817
GB
I have a command button on my form to import an excel file into a table but I would like to put a warning on it incase it is pressed accidentally. What is the best way of doing this?
 
Have a look at the MsgBox function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi There,
I tried that but it doesn't give the option of saying no.
 
I tried that but it doesn't give the option of saying no
Really ?
Msg = "Are you sure you want to do that?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Import Excel file"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
MsgBox "You said YES"
Else ' L'utilisateur a choisi Non.
MsgBox "You said NO"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi Again,
I'm sorry but I really don't understand that. I was hoping for a macro like the one I have to import the file but if that's not possible is there one to delete the file after I have updated the table, that would solve my problem.

Thanks.
 
Lars,

I don't think you can do what you want in Access macros. In fact there's a *long* list of things you can't do in Access macros - forget them, learn a bit of basic VBA, and then use the code PHV has posted for you. :)

Ed Metcalfe.

Please do not feed the trolls.....
 
Where do I attach the code to.
 
Lars,

Behind the button's On_Click event.

I'd suggest you do a Google for some beginners VB/VBA lessons to get you started.

Ed Metcalfe.

Please do not feed the trolls.....
 
Dosn't work,
Theres nowhere in the code to say which access file to import and on click is where the macro was to import the file.
 
Hey - here's a work around for you. Instead of having the button do the import, why dont you have it open another form. On this form put 2 buttons, make one the import button, make the other a cancel button...
 
lars7 wrote: 'Dosn't work,
Theres nowhere in the code to say which access file to import and on click is where the macro was to import the file.'

i assume the actual Macro works perfectly so you can just replace the 'MsgBox "You said YES"' with docmd.runmacro "nameofMacro"

A bit messy using VBA and Macros but will get the job doen while you learn the VBA basics.

Ian
 
Hi Taff,
I'm picking this up slowly. Your suggestion worked great.
Thanks


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top