?
Solved

Data Type Declaration Statements

Posted on 2011-03-14
10
Medium Priority
?
467 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35135077
Yes, that is a correct way of doing the declaration
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 200 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 - Microsoft MVP, Access and Data Platform) earned 800 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
 

Author Closing Comment

by:creativefusion
ID: 35135320
Perfect as expected.

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

mx
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

752 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