Solved

Invalid use of Property

Posted on 2004-09-27
11
374 Views
Last Modified: 2012-06-27
HI Experts,

The following code produces an "Invalid use of Property" Error, and I can't tell why, please help.

Private Sub txtPO_Exit(Cancel As Integer)

Dim SQL As String
Dim rst As Recordset
       
If Not IsNull(txtPO) Then
        SQL = "Select * From [Skid List] Where PO = '" & txtPO & "'"
        Set rst = CurrentDb.OpenRecordset(SQL)
           
        lblSkidsUsed.Visible = True
        NewSkid.Visible = True
        SkidList.Visible = True

        If rst.BOF And rst.EOF Then
            EditSkid.Visible = False
            PrintSkidLabel.Visible = False
            DeleteSkid.Visible = False
        Else
            EditSkid.Visible = True
            PrintSkidLabel.Visible = True
            DeleteSkid.Visible = True
        End If

End If
End Sub
0
Comment
Question by:IndyBean
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 36

Expert Comment

by:SidFishes
ID: 12163069
first try adding me! to each control

me!NewSkid.Visible = True

if that doesn't work which line doesn it break on?
0
 
LVL 1

Author Comment

by:IndyBean
ID: 12163087
It doesn't take me into the step through view of the code it's a message box error.

The me! seems not to have helped
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 12163137
you can either hit control-Break at the message box and select debug or

put a breakpoint at

If Not IsNull(txtPO) Then

to add a break point just put your cursor in the line you want and press F9

now run your code and step thru with F8
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:dannywareham
ID: 12163138
I take it that PO is a text-valued object?

Try changing:
SQL = "Select * From [Skid List] Where PO = '" & txtPO & "'"

to

SQL = "Select * From [skid list] Where PO = " & chr(34) & me.txtPO & chr(34) & """
0
 
LVL 1

Author Comment

by:IndyBean
ID: 12163188
The breakpoint didn't do it.

I don't know that it's the code. It's a message box that only allows "Okay".

---------------------------------------------------------------------------------------------------------\

The expression On Exit you entered as the event property setting produced the following error: Invalid use of Property.

*The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event or macro.

----------------------------------------------------------------------------------------------------------
0
 
LVL 1

Author Comment

by:IndyBean
ID: 12163200
I exited Access and went back in and now its the same message except the error is now

Variable not defined.
0
 
LVL 36

Accepted Solution

by:
SidFishes earned 125 total points
ID: 12163204
in your code window

select debug - compile..

.it -should- show you the error
0
 
LVL 77

Expert Comment

by:peter57r
ID: 12163207
Hello IndyBean,

> The following code produces an "Invalid use of Property" Error,
on which line?

Do you have a reference to DAO3.6 set?
If so do you have a reference to ActiveXDataObjects 2.n set?
If so remove the setting for ADO.

Pete
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 12163246
Alternatively, try:

SQL = "SELECT * FROM [skid list] "
SQL = SQL & "WHERE ((("[PO])= " & chr(34) & [me].[txtPO] & chr(34) &));"

The error will be formed as a result of the SQL statement - guaranteed....
0
 
LVL 1

Author Comment

by:IndyBean
ID: 12163257
Alright that's just rediculous. I had in another function; NewSkid_OnClick()

Dim rst As RecordSet

it didn't like the line apparently and said that rst later in the function was not defined.

It had nothing to do with the code I got the problem from.

It works fine now. Thank you
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 12163268
that's why the debug compile is useful...it will find all those undefined variables that give you strange error messages
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question