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

Compile error in previous access version

Status
Not open for further replies.

ScottCybak

Programmer
Sep 29, 2000
48
CA
Hello, i've been developping in acess 2000 since i began, and yesterday i installed XP - what a wonderfull upgrade, my mouse scroll works in listboxes, and most importantly, the OpenReport method supports opening arguments and the modal property.

Now, this database will be ran on 2000 versions as well, and i'm trying to create an optimized print sub routine, as i have a custom print dialog that i display. The sub routine uses:

If SysCmd(7) = 10 Then
'Code for XP version
Else
'Code for 2000 version
End If

To diffentiate the version used (this does work properly on access xp), BUT, if i open this in 2000, i get compile errors whenever i run the code.. and it freezes on my OpenReport line

Basically, i thought the compiler would skip this, as the version is 9 in 2k and it skips this due to the If statement, but it obviously doesn't.

The module was option explicit, but i removed it hoping that perhaps it would compile - no deal. There are about 10 computers running 2K and only 2 on XP.. how can i fix this? I search this and a few other sites, including the MSKB to no avail.

TIA Scott Cybak
scott@athree.com
 
I assume you're getting a compile error in the 'Code for XP version' part. The If statement will cause this code to be skipped at execution time, but you can't get to execution until the compiler has compiled the code. If the XP code contains any syntax that's new in XP, the Access 2000 compiler will have a problem trying to compile it.

You need to use Conditional Compilation. Normal If statements have this meaning:
If (the condition is true) Then
Execute this
Else
Execute this other
End If
Conditional compilation #If statements are similar, except they work at compile time to select which code to compile. They have this meaning:
#If (the #condition is true) Then
Compile this
#Else
Compile this other
#End If
In the #If statement, the "#condition" you would need would test a compiler constant defined by VBA which indicates its version. I haven't installed XP, so I don't know the appropriate constant for it, but for Access 2000 it's named "VBA6", so you could code:
#If VBA6 Then
'Code for Access 2000
#Else
'Code for Access XP
#End If

If this code doesn't work for you (it might not because I'm not sure that Access XP will recognize the VBA6 constant), try checking your Help for "conditional compilation". Rick Sprague
 
Rick,

Thanks for your response, i will test it out in a few hours when i get a chance, but i'm guessing that this will work.

If it does, i'll give you the purple star.

Thanks again,

Scott Scott Cybak
scott@athree.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top