Solved

Data Type Declaration Statements

Posted on 2011-03-14
10
462 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 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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 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
 

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

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.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

691 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