IndyBean
asked on
Invalid use of Property
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(SQ L)
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
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(SQ
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
ASKER
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
The me! seems not to have helped
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
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
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) & """
Try changing:
SQL = "Select * From [Skid List] Where PO = '" & txtPO & "'"
to
SQL = "Select * From [skid list] Where PO = " & chr(34) & me.txtPO & chr(34) & """
ASKER
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.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
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.
--------------------------
ASKER
I exited Access and went back in and now its the same message except the error is now
Variable not defined.
Variable not defined.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
> 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
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....
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....
ASKER
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
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
that's why the debug compile is useful...it will find all those undefined variables that give you strange error messages
me!NewSkid.Visible = True
if that doesn't work which line doesn it break on?