Solved

Data Type Declaration Statements

Posted on 2011-03-14
10
420 Views
Last Modified: 2012-06-22
All,

I am still getting my feet wet with devlopment so bare with me please!!

An easy question for you all I hope?

Can I declare mutiple variables and associated data types on one line of code in Access VBA?

I have enclosed a sample for you to see what I am doing.

CF
Dim vMAID As Long, vPodStateCode as Integer, vRefNo As Long, vDestLocNo As Long

Open in new window

0
Comment
Question by:creativefusion
  • 4
  • 3
  • 3
10 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 35135077
Yes, that is a correct way of doing the declaration
0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 50 total points
ID: 35135095
you can also do this

Dim vMAID As Long, vPodStateCode As Integer, _
    vRefNo As Long, vDestLocNo As Long
0
 
LVL 75
ID: 35135157


Dim vMAID As Long, vPodStateCode as Integer, vRefNo As Long, vDestLocNo As Long

Just noting ... when you do all the declarations on a single, be *sure* you data type each variable ... as you have done.

mx
0
 

Author Comment

by:creativefusion
ID: 35135291
Thanks guys.

So I couldn't do this right?

Dim vRefNo, vMAID as Long, vStateCode as Integer, vTest as String

Note: Both vRefNo and vMAID are Long data types...

CF
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 200 total points
ID: 35135309
To avoid problems down the road and minimize issues ... this is your best move:


Dim vRefNo As Long, vMAID as Long, vStateCode as Integer, vTest as String

Right off, I forget what can happen, but I'm pretty sure that w/o As Long for vRefNo ... it will be a Variant.

I prefer this scenario:


Dim vRefNo As Long, vMAID as Long
Dim vStateCode as Integer
Dim vTest as String

ie ... separate lines for each data type.

mx
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Closing Comment

by:creativefusion
ID: 35135320
Perfect as expected.

Thanks guys.
Shaun
0
 
LVL 75
ID: 35135333
you are welcome ..

mx
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 35137127
creativefusion,

your question states
<Can I declare mutiple variables and associated data types on one line of code in Access VBA? >

and that is already answered in http:#a35135077 
0
 

Author Comment

by:creativefusion
ID: 35137814
Hi Caps,

Mate, I aksed the original question and yes you answered it correctly first off. However, as a VB newbee ( and you know I am because you have answered many of my previous posts), we both know how dynamic programming can be to a blind man, so the question changed as I found an issue with another possible scenario beyond my initial post.

DatabseMX answered the additional questions I posted hense the reason why I awarded the most points to him.

Is it really supposed to be so confronting for a learner on EE?

Kind regards,
Shaun
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 35137916
<Is it really supposed to be so confronting for a learner on EE?>

no, but there are rules to be followed, (first correct answer gets the accepted answer)

0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now