Invalid identifier following null constant

I

Imran J Khan

I have a formA that opens to show either existing records or new record
depending on the cmd Button used to open it.
When open for new record, it opens without error. But when moving to a new
reocrd after opening either as a new reocrd or existing reocord, I have the
following error:
"-2147352567 (80020009)
There is an invalid use of the .(dot) or ! operator or invalid parenthses.
You may have entered an invalid identifier or typed parenthses following the
null constant."
I chose the debug button, and it takes me the this procedure:
Public Sub setDTId()
If Nz(DTId, "") = "" Then
DTId = "ABC"
End If
End Sub
The second line ' If Nz(deliveryTermId, "") = "" Then' is highlighted. If I
press F8, it comes up with the same error message above.

I can't fiqure out what is wronge.
Imran
 
D

Dale_Fye via AccessMonster.com

What is DTld?

You don't have this variable declared and you don't appear to be passing it
to the sub. Is it a global variable? If so, what is its data type?

How are you using this subroutine?

Dale
 
I

Imran J Khan

DTId is a textbox in FormA. Datatype is text (example "ABC").

I am using the routine on form.current event and on dblclick event of
another textbox in the same form. It is meant to check if DTId textbox is
empty, if it is, it should assign value "ABC".

The sub is Public, I don't remember making it that, could that be a reason.
I think it should work fine as private sub.

Thanks for your reply Dale.

Imran
 
D

Dale_Fye via AccessMonster.com

What happens if you try:

Public Sub setDTId()

me.DTld = NZ(DTId, "ABC)

End Sub

The method above will take care of NULLs, but not empty strings. The method
below will check for either NULL or ""

Public Sub setDTId()

if len(me.DTld & "") - 0 then me.DTld "ABC"

End Sub
DTId is a textbox in FormA. Datatype is text (example "ABC").

I am using the routine on form.current event and on dblclick event of
another textbox in the same form. It is meant to check if DTId textbox is
empty, if it is, it should assign value "ABC".

The sub is Public, I don't remember making it that, could that be a reason.
I think it should work fine as private sub.

Thanks for your reply Dale.

Imran
What is DTld?
[quoted text clipped - 25 lines]
 
I

Imran J Khan

Gave error improper use of me.
I removed me. because it is a class module for FormA.
Gave same error as fist post, except run-time error2447
Imran

Dale_Fye via AccessMonster.com said:
What happens if you try:

Public Sub setDTId()

me.DTld = NZ(DTId, "ABC)

End Sub

The method above will take care of NULLs, but not empty strings. The method
below will check for either NULL or ""

Public Sub setDTId()

if len(me.DTld & "") - 0 then me.DTld "ABC"

End Sub
DTId is a textbox in FormA. Datatype is text (example "ABC").

I am using the routine on form.current event and on dblclick event of
another textbox in the same form. It is meant to check if DTId textbox is
empty, if it is, it should assign value "ABC".

The sub is Public, I don't remember making it that, could that be a reason.
I think it should work fine as private sub.

Thanks for your reply Dale.

Imran
What is DTld?
[quoted text clipped - 25 lines]
I can't fiqure out what is wronge.
Imran
 
J

JimBurke via AccessMonster.com

Not clear on what you mean by 'it is a class module for FormA'. Is this code
in the code module of FormA itself (i.e. if you're in design mode in FormA
and you do a View, Code is it there)? Or is it in a separate module which
FormA accesses? If it's within FormA itself I can't see why that wouldn't
work. If it's in another module you need to qualify the control name, i.e.

Forms!FormA!CDtld

Not sure I got your control name right.

Gave error improper use of me.
I removed me. because it is a class module for FormA.
Gave same error as fist post, except run-time error2447
Imran
What happens if you try:
[quoted text clipped - 31 lines]
 
I

Imran J Khan

It is the code module of FormA itself.

JimBurke via AccessMonster.com said:
Not clear on what you mean by 'it is a class module for FormA'. Is this code
in the code module of FormA itself (i.e. if you're in design mode in FormA
and you do a View, Code is it there)? Or is it in a separate module which
FormA accesses? If it's within FormA itself I can't see why that wouldn't
work. If it's in another module you need to qualify the control name, i.e.

Forms!FormA!CDtld

Not sure I got your control name right.

Gave error improper use of me.
I removed me. because it is a class module for FormA.
Gave same error as fist post, except run-time error2447
Imran
What happens if you try:
[quoted text clipped - 31 lines]
I can't fiqure out what is wronge.
Imran
 
J

JimBurke via AccessMonster.com

I don't know - I use Nz all the time with textboxes with no problem. So
you're sure that 'DTId' is the actual textbox control name? Could it be the
name of the control source, where the actual control name is different? Take
a look at the text box's properties and verify that the Name property is
'Dtld'. If it is, it doesn't make any sense to me. One thing you can try,
though it shouldn't matter at all, is to use Dtld.Value in the Nz function.
But if all this code is in that form's code module and the control's name is
Dtld it shouldn't make any difference.

It is the code module of FormA itself.
Not clear on what you mean by 'it is a class module for FormA'. Is this code
in the code module of FormA itself (i.e. if you're in design mode in FormA
[quoted text clipped - 16 lines]
 
J

JimBurke via AccessMonster.com

If you refer to a control on a form you have to use me!ctlName, not me.
ctlName. That's why you got that particualr error. But you should never HAVE
to use Me like that - it's implied when you refer to the ctlName itself when
in that form's code module.
Gave error improper use of me.
I removed me. because it is a class module for FormA.
Gave same error as fist post, except run-time error2447
Imran
What happens if you try:
[quoted text clipped - 31 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top