Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

msgbox: Compilation error Invalid use of property 2

Status
Not open for further replies.

matrec

Technical User
Feb 19, 2005
19
CY
I have created a blank database and have imported into it all tables, forms, queries, reports, modules of my Access XP 2003 program.

When I open the program, I get the following Compile Error message: Invalid use of property. The mark goes onto: msgbox "My message" . I have checked the References and these are the same as those of the original program and in the same sequence:

Visual Basic for Applications
MS Aceess 11.0 object Library
MS DAO 3.6 Object Library
OLE Automation
MS ActiveX Date Objects 2.1 Library

Any hints as to where the problem might be ?

best rgds
 
Could you post the section of code where the Msgbox function is written?
 
Hi addy,
Here is the code:
Private Sub Form_Open(Cancel As Integer)
If userLevel = "V1" Or userLevel = "T2" Or userLevel = "T3" _
Or userLevel = "T1" Or userLevel = "P1" Then
msgbox "You have permission to view only"
DoCmd.CancelEvent
Exit Sub
End If
Call allowEditDeleteAdditionW(Me)
End Sub

Also in:
Private Sub btnFind_Click()
On Error GoTo Err_btnFind_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_btnFind_Click:
Exit Sub

Err_btnFind_Click:
msgbox err.description
Resume Exit_btnFind_Click

End Sub
in both above cases, the code is written in the same form.

Rgds
 
Does by chance the form have a control named msgbox ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
No, I have checked this. I forgot to mention that the problem occurs only in the fresh database where I imported all objects. The original program works without any problem.

Rgds
 
Unless there's some corruption going on, I would think PHV is spot on. Either a form control, or another object within the scope is named msgbox. One additional hint which makes me think this, is that all the rest of the code is "camelcased" while msgbox in what you've pasted, is lower case.

Until you've found this, try the workaround of prefixing the method/function with the library

[tt]VBA.msgbox "You have permission to view only"
' or
VBA.Interaction.msgbox "You have permission to view only"[/tt]

It could perhaps also bee a reference issue. Check if any is marked as missing, invalid... (uncheck and recheck the DAO library too, for safety;-) - but then you should get errors on other functions from that library too (mid, left...)

Roy-Vidar
 
VBA.msgbox "You have permission to view only" has worked.

But I find out that, in all cases that msgbox is used, this is written in low case letters instead of MsgBox. Now I remember that a few months ago, I used: Dim msgbox as string
but searching through the code now, I cannot find this. I am sure I have deleted it. Could this have caused the problem ?

Rgds
 
Replace VBA.MsgBox with msgbox, right click this word and choose definition.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
When I right-click in msgbox and choose definition there is a Visual Basic Message saying "Cannot jump to 'msgbox' because it is in the library 'C:\Documents ......... ' which is not currently referenced.
 
...which means it's probably a control on the form - I think there's a form control selector, either at the toolbar, or on the properties dialog, where you can select form controls - check there. Else, try a

[tt]appliation.saveastext acform, "frmThisForm", "c:\frmThisForm.txt"[/tt]

in the immediate pane (ctrl+g) to create a searchable text file "of the form", and look for it there.

Roy-Vidar
 
Roy-Vidar, addy, PHV
I have finally spotted in one of the tables "msgbox" as a field name. I deleted this field and compacted the database. Everything works fine and msgbox is written as MsgBox.
Thank you all for your valuable help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top