dim

A

Akrt48

Help; can some one please tell me what dim means as in Dim ename, then code
after it. I thought it was a diminutive of a name but I have tried making a
code and it will not work like the old one. This code works
Dim Ename
Ename = DLookup("Employeename", "Employeewages", "[Employeenumber]='" &
Me!EMPLOYEENUMBER & "'")
If Not IsNull(Ename) Then Me!EMPLOYEENAME = Ename

This doesn't
Dim Blk
blk= DLookup("Block", "Jobs", "[Jobnumber]='" & Me!Jobnumber & "'")
If Not IsNull(blk) Then Me!block = Blk

I obviously don't understand what Dim means

Thanks
 
T

Tom Lake

Akrt48 said:
Help; can some one please tell me what dim means as in Dim ename, then
code
after it. I thought it was a diminutive of a name but I have tried making
a
code and it will not work like the old one. This code works
Dim Ename
Ename = DLookup("Employeename", "Employeewages", "[Employeenumber]='" &

In this case Dim is just used to define a variable. If Option Explicit is
used, all variables
must be defined before use.

Tom Lake
 
J

John Vinson

Help; can some one please tell me what dim means as in Dim ename

Dim is short for the VERY old (way, way back from when I was first
learning programming, on FORTRAN II using punchcards) term
"Dimension". It's a way to reserve space for a variable and define its
datatype.

Dim ename As String

tells the VBA compiler that you will be using a variable named ename
somewhere in your code, and that you intend to use it to store string
data (as opposed to dates, or numbers, or some other type of data).

Dim ename

reserves space, but for the totally free-form and therefore
inefficient Variant datatype.


John W. Vinson[MVP]
 
P

Pat Hartman\(MVP\)

Your problem is probably not related to the Dim statement. If Jobnumber is
numeric, you need to remove the enclosing single quotes. Only text values
are delimited with quotes. Dates are delimited with pound signs (#).
Numeric values are not delimited at all.

blk= DLookup("Block", "Jobs", "[Jobnumber]=" & Me!Jobnumber)
 
A

Akrt48

Thank you Pat everyone else was a great help answering what I asked, but you
solved my problem!

Pat Hartman(MVP) said:
Your problem is probably not related to the Dim statement. If Jobnumber is
numeric, you need to remove the enclosing single quotes. Only text values
are delimited with quotes. Dates are delimited with pound signs (#).
Numeric values are not delimited at all.

blk= DLookup("Block", "Jobs", "[Jobnumber]=" & Me!Jobnumber)

Akrt48 said:
Help; can some one please tell me what dim means as in Dim ename, then
code
after it. I thought it was a diminutive of a name but I have tried making
a
code and it will not work like the old one. This code works
Dim Ename
Ename = DLookup("Employeename", "Employeewages", "[Employeenumber]='" &
Me!EMPLOYEENUMBER & "'")
If Not IsNull(Ename) Then Me!EMPLOYEENAME = Ename

This doesn't
Dim Blk
blk= DLookup("Block", "Jobs", "[Jobnumber]='" & Me!Jobnumber & "'")
If Not IsNull(blk) Then Me!block = Blk

I obviously don't understand what Dim means

Thanks
 
Top