I am having trouble getting a full understanding of how to use multiple if statements. I want to first use the msgbox, and if vb yes then import the two spreadsheets below with if statements here checking first if a file is present, is so then import them, if not import the blank file for both imports. Not really sure how to word this correctly but I and getting a compile error, Block If without End If. - Private Sub Command27_Click()
-
-
If MsgBox("Are you sure you want to import today's JRC Manifest?", vbYesNo, "Importing") = vbYes Then
-
If Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Inbound\In.xlxs") = "" Then
-
DoCmd.RunSavedImportExport "Import-In"
-
Else
-
DoCmd.RunSavedImportExport "Import-Inblk"
-
If Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Outbound\Out.xlxs") = "" Then
-
Else
-
DoCmd.RunSavedImportExport "Import-Outblk"
-
DoCmd.Requery ""
-
-
End If
-
-
End Sub
- Private Sub Command27_Click()
-
'Get confirmation from user
-
If vbYes=MsgBox("Are you sure you want to import today's JRC Manifest?", vbYesNo, "Importing") Then
-
'Check for file existance Inbound
-
If Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Inbound\In.xlxs") = "" Then
-
'File does not exist, import blank sheet
-
DoCmd.RunSavedImportExport "Import-In"
-
Else
-
'File exists, import
-
DoCmd.RunSavedImportExport "Import-Inblk"
-
End If
-
-
-
'Check for file existance outbound
-
If Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Outbound\Out.xlxs") = "" Then
-
'File does not exist, do nothing
-
Else
-
'File exists
-
DoCmd.RunSavedImportExport "Import-Outblk"
-
End If
-
-
'Done importing, update screen
-
DoCmd.Requery ""
-
End If
-
-
End Sub
4 1708 - Private Sub Command27_Click()
-
'Get confirmation from user
-
If vbYes=MsgBox("Are you sure you want to import today's JRC Manifest?", vbYesNo, "Importing") Then
-
'Check for file existance Inbound
-
If Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Inbound\In.xlxs") = "" Then
-
'File does not exist, import blank sheet
-
DoCmd.RunSavedImportExport "Import-In"
-
Else
-
'File exists, import
-
DoCmd.RunSavedImportExport "Import-Inblk"
-
End If
-
-
-
'Check for file existance outbound
-
If Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Outbound\Out.xlxs") = "" Then
-
'File does not exist, do nothing
-
Else
-
'File exists
-
DoCmd.RunSavedImportExport "Import-Outblk"
-
End If
-
-
'Done importing, update screen
-
DoCmd.Requery ""
-
End If
-
-
End Sub
I had to change a few things but I understand it a little bit better now. I am sorry on my lack of code logic, I a have only really built two databases for work in the military and it is nowhere in my normal job field. I appreciate the quick reply everything works now. Not used to posting code as well. I had to google code tags... -
Private Sub Command27_Click()
-
'Get confirmation from user
-
If vbYes = MsgBox("Are you sure you want to import today's JRC Manifest?", vbYesNo, "Importing") Then
-
'Check for file existance Inbound
-
If Len(Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Inbound\In.xlsx")) = "0" Then
-
'File does not exist, import blank sheet
-
DoCmd.RunSavedImportExport "Import-Inblk"
-
Else
-
'File exists, import
-
DoCmd.RunSavedImportExport "Import-In"
-
-
End If
-
-
-
'Check for file existance outbound
-
If Len(Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Outbound\Out.xlsx")) = "0" Then
-
'File does not exist, import blank sheet
-
DoCmd.RunSavedImportExport "Import-Outblk"
-
Else
-
'File exists, import
-
DoCmd.RunSavedImportExport "Import-Out"
-
End If
-
-
'Done importing, update screen
-
DoCmd.Requery ""
-
End If
-
-
End Sub
NeoPa 32,556
Expert Mod 16PB Stevan Bias:
Not used to posting code as well. I had to google code tags...
Well, that sets you apart from most members then :-) Most just ignore them. You've done a good job even without any prior understanding.
As a tip for a new user who obviously has the intelligence and attitude to get things done, check out Context-Sensitive Help. You will find so much to help you get going, even with things you've not come across before in VBA.
NeoPa,
I appreciate the Tip. I will definitely utilize that. I have a lot to learn in Access and any help Is depreciated.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Shmuel |
last post by:
Is it possible to query multiple statements at once?
Like:
$query = "set @p := 1; select @p + 1";
$results = mysql_query($query);
I'm thinking of PHP4. There is in mysqli the prepare...
|
by: Richard Adams |
last post by:
Is it possible to execute more than one statement in SQL via MDAC
ODBC? I have a fairly complex select I wanted to create a view with,
but trying to send it all as one string with terminators ';'...
|
by: Erik Haugen |
last post by:
This item in the C++ faq:
http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-38.5
discusses macros with multiple statements.
The problem is that a macro such as
#define...
|
by: DG |
last post by:
Hi,
Can anyone advise how to execute multiple statements in a single query
batch. For example-
update customers set customer_name = 'Smith' where customer_name =
'Smyth';
select * from...
|
by: Nabil |
last post by:
I am new to DB2 and here is my situation.
I have 2 temp tables where I am trying to insert data (from 2 select
statements)
DECLARE v_t1 VARCHAR(50);
DECLARE v_t1 VARCHAR(50);
DECLARE stmt1...
|
by: Annie D via AccessMonster.com |
last post by:
Hi,
Is it possible to use multiple statements in SQL?? (I’ve never used it before)
:
I have one query that i'm working with, The statements I want to use are as
below, they all work...
|
by: arthy |
last post by:
Hi,
Is it possible to execute multiple statements on to the database using a single dbconnection object.what is the drawback in using .If not possible ,then how can the execution of multiple...
|
by: paladin.rithe |
last post by:
I have 2 statements that I'd like to string together in a query, but
according to everything I'm seeing, it's not possible.
What I'm doing is an insert of a row, where the primary key is an auto...
|
by: jodleren |
last post by:
another topic though related to the previous post.
How do IF behave in php?
Say,
if( $goahead && copy($somefile1, $somefile2) )
echo "hello world";
What if $goahead is false, will the if...
|
by: harsha318 |
last post by:
Hi
I need to have a single query and which can have multiple statements
For eg:
string str = string.Empty;
str = "select * from Customers;Select * from Orders";
iDB2Connection iDB2con =...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |