if block not executed

Mirica_Victor

Registered User.
Local time
Today, 08:26
Joined
Oct 24, 2008
Messages
11
Hy, I have a problem: on a open form event i have the folowing code:
Code:
Private Sub Form_Open(Cancel As Integer)
Dim Dimensiune As Double
Dimensiune = FileLen("path_to_self_mdb_file") / 1024 / 1024
If Dimensiune > 500 Then
SendKeys "%tdc"
Else
End if
 
[Code to run] 
 
End Sub

In this format the if block is not run at all. It runs after I have put the code to be runned between Else and End if, only then the if block is executed and the dimensions of the mdb file is checked and the compact is conditionally executed. Anny ideeas why?
 
How big is the file you are getting the size of?
 
Well, the purpose is not to let the code run and make the *.mdb file get over 2 Gb, so if the file is over 500 Mb, then compact is executed. I already have this code used in another database But the code there is between Elese ... End If.

I do not think the size is relevant, I think is a logical problem..... Wich I do not get....
 
i would try using DIR to make sure the file you are using DOES exist.

the other issue might be that because maxint in vba is 2Gb (or so) - you will get a strange overflow value for files of length greater than 2Gb - which might cause your test to fail

I was trying to examine large files in vba recently, and couldn't see a way around this.
 

Users who are viewing this thread

Back
Top Bottom