Strange Problem

A

alex

Using Access ’03…

I need help doing something that I’ve done a thousand times!

An hour before this post the code below worked:

Private Sub txtTest_Enter()
'check to see if lstConveyed is null
If IsNull(lstConveyed) Then
MsgBox ("Please choose Conveyed Message")
lstConveyed.SetFocus
Else
End If
End Sub

All of a sudden I’m getting “Invalid use of property” Compile error on
the msgbox.

I must have done something to the form because I cannot even place a
simple msgbox in the on click event of a command button. I get the
same error.

Thoughts?
alex
 
D

Damon Heron

does
Msgbox "Please choose....", 0,"Message"
work?

Damon

Using Access ’03…

I need help doing something that I’ve done a thousand times!

An hour before this post the code below worked:

Private Sub txtTest_Enter()
'check to see if lstConveyed is null
If IsNull(lstConveyed) Then
MsgBox ("Please choose Conveyed Message")
lstConveyed.SetFocus
Else
End If
End Sub

All of a sudden I’m getting “Invalid use of property” Compile error on
the msgbox.

I must have done something to the form because I cannot even place a
simple msgbox in the on click event of a command button. I get the
same error.

Thoughts?
alex
 
A

alex

does
Msgbox "Please choose....", 0,"Message"
work?

Damon


Using Access ’03…

I need help doing something that I’ve done a thousand times!

An hour before this post the code below worked:

Private Sub txtTest_Enter()
    'check to see if lstConveyed is null
    If IsNull(lstConveyed) Then
        MsgBox ("Please choose Conveyed Message")
        lstConveyed.SetFocus
    Else
    End If
End Sub

All of a sudden I’m getting “Invalid use of property” Compile erroron
the msgbox.

I must have done something to the form because I cannot even place a
simple msgbox in the on click event of a command button.  I get the
same error.

Thoughts?
alex

Hey Damon,
Thanks for responding.

For some reason that I cannot explain; it now works, as i originally
posted.
I'll keep your code in case it craps out again...
Maybe some of the MVPs will see this and know exactly what i did
wrong.

Thanks again,
alex
 
D

Dorian

When error points to an IF ... Then, it could be any statement inside the IF
Sounds like it could be your setfocus statement.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
D

Douglas J. Steele

Damon's correct that you should not have the parentheses around the message.

There are two ways to use MsgBox: as a function and as a statement.
Including the parentheses implies you're trying to use it as a function, yet
you're not capturing the results of running it.

That having been said, I'd have expected a different error message, so I
suspect something funky's happening to your database. Hopefully you've got a
recent backup, in case it stops working completely.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


does
Msgbox "Please choose....", 0,"Message"
work?

Damon


Using Access ’03…

I need help doing something that I’ve done a thousand times!

An hour before this post the code below worked:

Private Sub txtTest_Enter()
'check to see if lstConveyed is null
If IsNull(lstConveyed) Then
MsgBox ("Please choose Conveyed Message")
lstConveyed.SetFocus
Else
End If
End Sub

All of a sudden I’m getting “Invalid use of property” Compile error on
the msgbox.

I must have done something to the form because I cannot even place a
simple msgbox in the on click event of a command button. I get the
same error.

Thoughts?
alex

Hey Damon,
Thanks for responding.

For some reason that I cannot explain; it now works, as i originally
posted.
I'll keep your code in case it craps out again...
Maybe some of the MVPs will see this and know exactly what i did
wrong.

Thanks again,
alex
 
A

alex

Damon's correct that you should not have the parentheses around the message.

There are two ways to use MsgBox: as a function and as a statement.
Including the parentheses implies you're trying to use it as a function, yet
you're not capturing the results of running it.

That having been said, I'd have expected a different error message, so I
suspect something funky's happening to your database. Hopefully you've got a
recent backup, in case it stops working completely.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)











Hey Damon,
Thanks for responding.

For some reason that I cannot explain; it now works, as i originally
posted.
I'll keep your code in case it craps out again...
Maybe some of the MVPs will see this and know exactly what i did
wrong.

Thanks again,
alex- Hide quoted text -

- Show quoted text -

Doug,
I agree with you on the funky part!
I didn't know that about the parentheses; thanks for the info.

The problem was definitely the msgbox, however. I commented out the
msgbox and everything worked fine. I've written dozens of msgboxes
with () and never had a problem. I'll stop using them sans function
from now on though.

alex
 

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