Solved

Data Type Declaration Statements

Posted on 2011-03-14
10
455 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

742 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