VBA Variable Won't Set

C

Can

I have a very bizarre error. The values for the New_Male_Sub, etc won't set
to the field that I am assigning it to. I run through the code and it stay
zero. It does set if I add a breakpoint for the line where I assign it.
Huh? It makes no sense. What am I doing wrong, any help is appreciated.

Dim New_Males_Sub As Integer
Dim New_Females_Sub As Integer
Dim New_Unknowns_Sub As Integer

New_Males_Sub = 0
New_Females_Sub = 0
New_Unknowns_Sub = 0

New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
New_Females_Sub = [Sum_Location_New_Tanks_TotalFemales]
New_Unknowns_Sub = [Sum_Location_New_Tanks_TotalUnknown]
 
D

Douglas J. Steele

What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?

If they're controls on your form, prefix them with Me.
 
C

Can

Made the changes. Tried a couple of variations with square breackets and
..value ... still doesn't work. :-(

Douglas J. Steele said:
What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?

If they're controls on your form, prefix them with Me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Can said:
I have a very bizarre error. The values for the New_Male_Sub, etc won't
set
to the field that I am assigning it to. I run through the code and it
stay
zero. It does set if I add a breakpoint for the line where I assign it.
Huh? It makes no sense. What am I doing wrong, any help is appreciated.

Dim New_Males_Sub As Integer
Dim New_Females_Sub As Integer
Dim New_Unknowns_Sub As Integer

New_Males_Sub = 0
New_Females_Sub = 0
New_Unknowns_Sub = 0

New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
New_Females_Sub = [Sum_Location_New_Tanks_TotalFemales]
New_Unknowns_Sub = [Sum_Location_New_Tanks_TotalUnknown]
 
C

Can

Nope but the sub is public. I had used the varaible same names in another
function so I added the _Sub

Klatuu said:
Check to see if you have that variable also dimmed at the module level.

Can said:
I have a very bizarre error. The values for the New_Male_Sub, etc won't set
to the field that I am assigning it to. I run through the code and it stay
zero. It does set if I add a breakpoint for the line where I assign it.
Huh? It makes no sense. What am I doing wrong, any help is appreciated.

Dim New_Males_Sub As Integer
Dim New_Females_Sub As Integer
Dim New_Unknowns_Sub As Integer

New_Males_Sub = 0
New_Females_Sub = 0
New_Unknowns_Sub = 0

New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
New_Females_Sub = [Sum_Location_New_Tanks_TotalFemales]
New_Unknowns_Sub = [Sum_Location_New_Tanks_TotalUnknown]
 
D

Douglas J. Steele

You didn't answer my question. What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Can said:
Made the changes. Tried a couple of variations with square breackets and
.value ... still doesn't work. :-(

Douglas J. Steele said:
What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?

If they're controls on your form, prefix them with Me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Can said:
I have a very bizarre error. The values for the New_Male_Sub, etc
won't
set
to the field that I am assigning it to. I run through the code and it
stay
zero. It does set if I add a breakpoint for the line where I assign
it.
Huh? It makes no sense. What am I doing wrong, any help is
appreciated.

Dim New_Males_Sub As Integer
Dim New_Females_Sub As Integer
Dim New_Unknowns_Sub As Integer

New_Males_Sub = 0
New_Females_Sub = 0
New_Unknowns_Sub = 0

New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
New_Females_Sub = [Sum_Location_New_Tanks_TotalFemales]
New_Unknowns_Sub = [Sum_Location_New_Tanks_TotalUnknown]
 
C

Can

Whoops, they are controls on my form. I am just confused why would code not
work then start working when the only difference is putting a burgundy dot
beside it to step through the code.

When I put the break after it and put my mouse over the code that isn't
working it will give values like
New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
0 = 2

It will read the correct value for [Sum_Location_New_Tanks_TotalMales] but
not set New_Males_Sub to it unless I put the break in.

Huh?

Douglas J. Steele said:
You didn't answer my question. What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Can said:
Made the changes. Tried a couple of variations with square breackets and
.value ... still doesn't work. :-(

Douglas J. Steele said:
What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?

If they're controls on your form, prefix them with Me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have a very bizarre error. The values for the New_Male_Sub, etc
won't
set
to the field that I am assigning it to. I run through the code and it
stay
zero. It does set if I add a breakpoint for the line where I assign
it.
Huh? It makes no sense. What am I doing wrong, any help is
appreciated.

Dim New_Males_Sub As Integer
Dim New_Females_Sub As Integer
Dim New_Unknowns_Sub As Integer

New_Males_Sub = 0
New_Females_Sub = 0
New_Unknowns_Sub = 0

New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
New_Females_Sub = [Sum_Location_New_Tanks_TotalFemales]
New_Unknowns_Sub = [Sum_Location_New_Tanks_TotalUnknown]
 
D

Douglas J. Steele

Not sure I understand what you're describing.

When you mouse over the code, New_Males_Sub won't be set to 2 until the line
has finished executing.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Can said:
Whoops, they are controls on my form. I am just confused why would code
not
work then start working when the only difference is putting a burgundy dot
beside it to step through the code.

When I put the break after it and put my mouse over the code that isn't
working it will give values like
New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
0 = 2

It will read the correct value for [Sum_Location_New_Tanks_TotalMales] but
not set New_Males_Sub to it unless I put the break in.

Huh?

Douglas J. Steele said:
You didn't answer my question. What are
[Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Can said:
Made the changes. Tried a couple of variations with square breackets
and
.value ... still doesn't work. :-(

:

What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?

If they're controls on your form, prefix them with Me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have a very bizarre error. The values for the New_Male_Sub, etc
won't
set
to the field that I am assigning it to. I run through the code and
it
stay
zero. It does set if I add a breakpoint for the line where I assign
it.
Huh? It makes no sense. What am I doing wrong, any help is
appreciated.

Dim New_Males_Sub As Integer
Dim New_Females_Sub As Integer
Dim New_Unknowns_Sub As Integer

New_Males_Sub = 0
New_Females_Sub = 0
New_Unknowns_Sub = 0

New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
New_Females_Sub = [Sum_Location_New_Tanks_TotalFemales]
New_Unknowns_Sub = [Sum_Location_New_Tanks_TotalUnknown]
 
C

Can

Yes I understand that. I put my burgundy dot within the function after that
line to read the values of the line in question (putting my mouse over it).
When I also put the burgundy dot on the line in question the line executes.
If I don't put the burgundy dot on the line in question, the line does not
execute. The burgundy dot is the only difference. In 8 years of working in
Access / VBA I've never seen this. I am confused.

Candace

Douglas J. Steele said:
Not sure I understand what you're describing.

When you mouse over the code, New_Males_Sub won't be set to 2 until the line
has finished executing.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Can said:
Whoops, they are controls on my form. I am just confused why would code
not
work then start working when the only difference is putting a burgundy dot
beside it to step through the code.

When I put the break after it and put my mouse over the code that isn't
working it will give values like
New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
0 = 2

It will read the correct value for [Sum_Location_New_Tanks_TotalMales] but
not set New_Males_Sub to it unless I put the break in.

Huh?

Douglas J. Steele said:
You didn't answer my question. What are
[Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Made the changes. Tried a couple of variations with square breackets
and
.value ... still doesn't work. :-(

:

What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?

If they're controls on your form, prefix them with Me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have a very bizarre error. The values for the New_Male_Sub, etc
won't
set
to the field that I am assigning it to. I run through the code and
it
stay
zero. It does set if I add a breakpoint for the line where I assign
it.
Huh? It makes no sense. What am I doing wrong, any help is
appreciated.

Dim New_Males_Sub As Integer
Dim New_Females_Sub As Integer
Dim New_Unknowns_Sub As Integer

New_Males_Sub = 0
New_Females_Sub = 0
New_Unknowns_Sub = 0

New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
New_Females_Sub = [Sum_Location_New_Tanks_TotalFemales]
New_Unknowns_Sub = [Sum_Location_New_Tanks_TotalUnknown]
 
D

Douglas J. Steele

Sorry, I haven't seen it either.

You might try creating a new form, and copying everything from the old one
to the new one, just in case it's mild corruption.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Can said:
Yes I understand that. I put my burgundy dot within the function after
that
line to read the values of the line in question (putting my mouse over
it).
When I also put the burgundy dot on the line in question the line
executes.
If I don't put the burgundy dot on the line in question, the line does not
execute. The burgundy dot is the only difference. In 8 years of working
in
Access / VBA I've never seen this. I am confused.

Candace

Douglas J. Steele said:
Not sure I understand what you're describing.

When you mouse over the code, New_Males_Sub won't be set to 2 until the
line
has finished executing.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Can said:
Whoops, they are controls on my form. I am just confused why would
code
not
work then start working when the only difference is putting a burgundy
dot
beside it to step through the code.

When I put the break after it and put my mouse over the code that isn't
working it will give values like
New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
0 = 2

It will read the correct value for [Sum_Location_New_Tanks_TotalMales]
but
not set New_Males_Sub to it unless I put the break in.

Huh?

:

You didn't answer my question. What are
[Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Made the changes. Tried a couple of variations with square
breackets
and
.value ... still doesn't work. :-(

:

What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?

If they're controls on your form, prefix them with Me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have a very bizarre error. The values for the New_Male_Sub,
etc
won't
set
to the field that I am assigning it to. I run through the code
and
it
stay
zero. It does set if I add a breakpoint for the line where I
assign
it.
Huh? It makes no sense. What am I doing wrong, any help is
appreciated.

Dim New_Males_Sub As Integer
Dim New_Females_Sub As Integer
Dim New_Unknowns_Sub As Integer

New_Males_Sub = 0
New_Females_Sub = 0
New_Unknowns_Sub = 0

New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
New_Females_Sub = [Sum_Location_New_Tanks_TotalFemales]
New_Unknowns_Sub = [Sum_Location_New_Tanks_TotalUnknown]
 
C

Can

Tried it and no luck. Any other ideas?

:-(

Douglas J. Steele said:
Sorry, I haven't seen it either.

You might try creating a new form, and copying everything from the old one
to the new one, just in case it's mild corruption.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Can said:
Yes I understand that. I put my burgundy dot within the function after
that
line to read the values of the line in question (putting my mouse over
it).
When I also put the burgundy dot on the line in question the line
executes.
If I don't put the burgundy dot on the line in question, the line does not
execute. The burgundy dot is the only difference. In 8 years of working
in
Access / VBA I've never seen this. I am confused.

Candace

Douglas J. Steele said:
Not sure I understand what you're describing.

When you mouse over the code, New_Males_Sub won't be set to 2 until the
line
has finished executing.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Whoops, they are controls on my form. I am just confused why would
code
not
work then start working when the only difference is putting a burgundy
dot
beside it to step through the code.

When I put the break after it and put my mouse over the code that isn't
working it will give values like
New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
0 = 2

It will read the correct value for [Sum_Location_New_Tanks_TotalMales]
but
not set New_Males_Sub to it unless I put the break in.

Huh?

:

You didn't answer my question. What are
[Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Made the changes. Tried a couple of variations with square
breackets
and
.value ... still doesn't work. :-(

:

What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?

If they're controls on your form, prefix them with Me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have a very bizarre error. The values for the New_Male_Sub,
etc
won't
set
to the field that I am assigning it to. I run through the code
and
it
stay
zero. It does set if I add a breakpoint for the line where I
assign
it.
Huh? It makes no sense. What am I doing wrong, any help is
appreciated.

Dim New_Males_Sub As Integer
Dim New_Females_Sub As Integer
Dim New_Unknowns_Sub As Integer

New_Males_Sub = 0
New_Females_Sub = 0
New_Unknowns_Sub = 0

New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
New_Females_Sub = [Sum_Location_New_Tanks_TotalFemales]
New_Unknowns_Sub = [Sum_Location_New_Tanks_TotalUnknown]
 
D

Douglas J. Steele

Sorry, no.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Can said:
Tried it and no luck. Any other ideas?

:-(

Douglas J. Steele said:
Sorry, I haven't seen it either.

You might try creating a new form, and copying everything from the old
one
to the new one, just in case it's mild corruption.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Can said:
Yes I understand that. I put my burgundy dot within the function
after
that
line to read the values of the line in question (putting my mouse over
it).
When I also put the burgundy dot on the line in question the line
executes.
If I don't put the burgundy dot on the line in question, the line does
not
execute. The burgundy dot is the only difference. In 8 years of
working
in
Access / VBA I've never seen this. I am confused.

Candace

:

Not sure I understand what you're describing.

When you mouse over the code, New_Males_Sub won't be set to 2 until
the
line
has finished executing.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Whoops, they are controls on my form. I am just confused why would
code
not
work then start working when the only difference is putting a
burgundy
dot
beside it to step through the code.

When I put the break after it and put my mouse over the code that
isn't
working it will give values like
New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
0 = 2

It will read the correct value for
[Sum_Location_New_Tanks_TotalMales]
but
not set New_Males_Sub to it unless I put the break in.

Huh?

:

You didn't answer my question. What are
[Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Made the changes. Tried a couple of variations with square
breackets
and
.value ... still doesn't work. :-(

:

What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?

If they're controls on your form, prefix them with Me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have a very bizarre error. The values for the New_Male_Sub,
etc
won't
set
to the field that I am assigning it to. I run through the
code
and
it
stay
zero. It does set if I add a breakpoint for the line where I
assign
it.
Huh? It makes no sense. What am I doing wrong, any help is
appreciated.

Dim New_Males_Sub As Integer
Dim New_Females_Sub As Integer
Dim New_Unknowns_Sub As Integer

New_Males_Sub = 0
New_Females_Sub = 0
New_Unknowns_Sub = 0

New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
New_Females_Sub = [Sum_Location_New_Tanks_TotalFemales]
New_Unknowns_Sub = [Sum_Location_New_Tanks_TotalUnknown]
 
C

Can

I got it working. I took the code out of that sub and put it in it's own.
Then I call that new sub within the original sub and it works great ....
silly but it works so I am happy.

:-D

Douglas J. Steele said:
Sorry, no.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Can said:
Tried it and no luck. Any other ideas?

:-(

Douglas J. Steele said:
Sorry, I haven't seen it either.

You might try creating a new form, and copying everything from the old
one
to the new one, just in case it's mild corruption.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Yes I understand that. I put my burgundy dot within the function
after
that
line to read the values of the line in question (putting my mouse over
it).
When I also put the burgundy dot on the line in question the line
executes.
If I don't put the burgundy dot on the line in question, the line does
not
execute. The burgundy dot is the only difference. In 8 years of
working
in
Access / VBA I've never seen this. I am confused.

Candace

:

Not sure I understand what you're describing.

When you mouse over the code, New_Males_Sub won't be set to 2 until
the
line
has finished executing.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Whoops, they are controls on my form. I am just confused why would
code
not
work then start working when the only difference is putting a
burgundy
dot
beside it to step through the code.

When I put the break after it and put my mouse over the code that
isn't
working it will give values like
New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
0 = 2

It will read the correct value for
[Sum_Location_New_Tanks_TotalMales]
but
not set New_Males_Sub to it unless I put the break in.

Huh?

:

You didn't answer my question. What are
[Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Made the changes. Tried a couple of variations with square
breackets
and
.value ... still doesn't work. :-(

:

What are [Sum_Location_New_Tanks_TotalMales],
[Sum_Location_New_Tanks_TotalFemales] and
[Sum_Location_New_Tanks_TotalUnknown] supposed to be?

If they're controls on your form, prefix them with Me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have a very bizarre error. The values for the New_Male_Sub,
etc
won't
set
to the field that I am assigning it to. I run through the
code
and
it
stay
zero. It does set if I add a breakpoint for the line where I
assign
it.
Huh? It makes no sense. What am I doing wrong, any help is
appreciated.

Dim New_Males_Sub As Integer
Dim New_Females_Sub As Integer
Dim New_Unknowns_Sub As Integer

New_Males_Sub = 0
New_Females_Sub = 0
New_Unknowns_Sub = 0

New_Males_Sub = [Sum_Location_New_Tanks_TotalMales]
New_Females_Sub = [Sum_Location_New_Tanks_TotalFemales]
New_Unknowns_Sub = [Sum_Location_New_Tanks_TotalUnknown]
 
Top