Dim

Finchy

Registered User.
Local time
Today, 15:46
Joined
Jul 15, 2010
Messages
14
Hello all,

I am relatively new to Access but am getting really in to this VBA. I just have a quick question about 'DIM' in code.

I programmed a button so 'on click' it performed its function and at the end it asks the user if they would like to open another database. I used to the following code:

msgbox ("Would you like to run the Availabilty?", VBYesNo, "Export Finished")
If vbyes = true then
Shell etc etc.....

Else

End if

Now quite clearily this doesn't work and after consulting my VBA for dummies it turns out that it needed to be something along the lines of:

DIM answer as Integer
Answer = MsgBox("Would you like to run the Availabilty?", VBYesNo, "Export Finished")
If answer = VByes then
Shell etc etc.....

My question is, what exaclty is the DIM function doing? Looking at other code it seems fundamental to VBA and yet I cant get my head round its purpose. I would be grateful if someone could explain this to me??

Thanks,

Finchy!
 
Hello all,

I am relatively new to Access but am getting really in to this VBA. I just have a quick question about 'DIM' in code.

I programmed a button so 'on click' it performed its function and at the end it asks the user if they would like to open another database. I used to the following code:

msgbox ("Would you like to run the Availabilty?", VBYesNo, "Export Finished")
If vbyes = true then
Shell etc etc.....

Else

End if

Now quite clearily this doesn't work and after consulting my VBA for dummies it turns out that it needed to be something along the lines of:

DIM answer as Integer
Answer = MsgBox("Would you like to run the Availabilty?", VBYesNo, "Export Finished")
If answer = VByes then
Shell etc etc.....

My question is, what exaclty is the DIM function doing? Looking at other code it seems fundamental to VBA and yet I cant get my head round its purpose. I would be grateful if someone could explain this to me??

Thanks,

Finchy!

Finchy,

TIP: place your cursor on the VBA keyword and press F1. This should give you the Access help file.

Dim Statement

Declares variables and allocates storage space.

...


I like to write the code this way:

Code:
If msgbox ("Would you like to run the Availabilty?", VBYesNo, "Export Finished") = vbYes Then 

     Shell etc etc.....

Else

End if
 

Users who are viewing this thread

Back
Top Bottom