Compile Error Invalid Use Of Property
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting compile error invalid use of property vba ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the compile error invalid use of property excel vba Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a
Compile Error Invalid Outside Procedure
minute: Sign up VBA - Compile Error: Invalid use of property up vote 0 down vote favorite I am trying to count the no of elements in a recordset after a query. I am doing this Function Test() As Variant Dim
Compile Error Invalid Use Of Me Keyword
rst As DAO.Recordset rst = CurrentDb.OpenRecordset("SELECT salary_total FROM CompSal") rst.MoveLast rst.MoveFirst Test = rst.RecordCount End Function I get this compile error: invalid use of property How to make this work? vba ms-access share|improve this question edited Jun 4 '15 at 9:19 Raptor 26.8k24123218 asked Jun 4 '15 at 9:18 user1670773 373215 where does this error occur? which line? –Raptor Jun 4 '15 at 9:19 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted rst is compile error invalid qualifier declared as a Recordset object. Any object need to be Set before it is being used. Unlike variables, they cannot be assigned they need to be Set. Also if possible, try and clean up the objects. So try, Function Test() As Variant Dim rst As DAO.Recordset Set rst = CurrentDb.OpenRecordset("SELECT salary_total FROM CompSal") rst.MoveLast rst.MoveFirst Test = rst.RecordCount Set rst = Nothing End Function However, you can also simply use a DCount, which does exactly the same. Test = DCount("*", "CompSal") This would be a lot easier than creating an object, Moving in the Recordset, all to get a count. share|improve this answer answered Jun 4 '15 at 9:38 PaulFrancis 4,8511727 add a comment| up vote 1 down vote Your code is fine apart from one minor error, you forgot to put Set in front of the rst = code: ... Set rst = CurrentDb.OpenRecordset("SELECT salary_total FROM CompSal") ... It should work like a charm after that share|improve this answer answered Jun 4 '15 at 9:24 Martin Parkin 4,111623 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged vba ms-access or ask your own question. asked 1 y
Forum Microsoft Office Application Help - Excel Help forum Excel Programming / VBA / Macros [SOLVED] Compile Error: Invalid Use of Property on stupidly simple code To get replies by our experts at nominal charges,
Compile Error Invalid Outside Procedure Access
follow this link to buy points and post your thread in our Commercial Services invalid use of property vba range forum! Here is the FAQ for this forum. + Reply to Thread Results 1 to 6 of 6 Compile Error: Invalid invalid use of property vba call Use of Property on stupidly simple code Thread Tools Show Printable Version Subscribe to this Thread… Rate This Thread Current Rating Excellent Good Average Bad Terrible Display Linear Mode http://stackoverflow.com/questions/30639837/vba-compile-error-invalid-use-of-property Switch to Hybrid Mode Switch to Threaded Mode 04-18-2013,10:26 AM #1 QueeniePie View Profile View Forum Posts Registered User Join Date 04-11-2013 Location Derby, England MS-Off Ver Excel 2007 Posts 4 Compile Error: Invalid Use of Property on stupidly simple code Evening all, I have a userform with a button on it. That button, when clicked, should call a separate macro. So far I haven't made the separate http://www.excelforum.com/showthread.php?t=916128 macro all that difficult as I am just testing things out. Also I'm pretty sure I've done this before and it worked just fine but at this point I'm getting compile error: invalid use of property. The Userform code reads: Please Login or Register to view this content. and in a separate module the temporary code reads: Please Login or Register to view this content. Any idea what I can be missing? That really is the only code in my worksheet at the moment and running through the ClearVehicles Sub manually will pop up a happy little MsgBox as I told it to. Register To Reply 04-18-2013,10:33 AM #2 Norie View Profile View Forum Posts Forum Guru Join Date 02-02-2005 Location Stirling MS-Off Ver Microsoft Office 2010 Posts 16,233 Re: Compile Error: Invalid Use of Property on stupidly simple code Can't replicate the error. Is that definitely the only code in the workbook? Do you get a debug option when you get the error message? If you don't goto Tools>Options... and on the General tab select Break on all Errors or Break in Class Module, then try the code again. If posting code please use code tags,
Forums Excel Questions Compile Error Invalid use of property Page 1 of 3 123 Last Jump to page: Results 1 to 10 of 23 Compile Error Invalid use of propertyThis is a discussion on Compile Error Invalid use of http://www.mrexcel.com/forum/excel-questions/603060-compile-error-invalid-use-property.html property within the Excel Questions forums, part of the Question Forums category; I am in th process of switching over from a worksheet to vba code. I am stuck on one are ... LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools Show Printable Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Jan 5th, 2012,07:06 AM #1 larrygreg compile error New Member Join Date Dec 2011 Posts 46 Compile Error Invalid use of property I am in th process of switching over from a worksheet to vba code. I am stuck on one are with table lookups. Code in the workbook is; =IFERROR(IF(XXX="XXX",VLOOKUP(XXXX,'Directory[EXCEL FILE]SHEET'!$A:$E,5,0)) In my VBA Code, I have; If Selection.Value = "XXXX" Then ActiveCell.Offset(0, 3).Select ActiveCell.FormulaR1C1 "=IFERROR(VLOOKUP(R[0]C[-1], '[File]Sheet'!$A:$E,5,0"""")" End If I get a compile error of Invalid use of property. Any suggestions. Thanks compile error invalid Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Jan 5th, 2012,07:10 AM #2 VoG MrExcel MVP Join Date Jun 2002 Location 127.0.0.1 Posts 63,652 Re: Compile Error Invalid use of property Try Code: ActiveCell.FormulaR1C1 "=IFERROR(VLOOKUP(RC[-1], '[File]Sheet'!$A:$E,5,0,"""")" Share Share this post on Digg Del.icio.us Technorati Twitter HTH, Peter Please test any code on a copy of your workbook. Reply With Quote Jan 5th, 2012,07:13 AM #3 Firefly2012 Board Regular Join Date Dec 2011 Posts 3,638 Re: Compile Error Invalid use of property I think you'd need: Code: ActiveCell.FormulaR1C1 "=IFERROR(VLOOKUP(RC[-1], '[File]Sheet'!C1:C5,5,0),"""")" But note that the '[File]Sheet' does need to be a valid file name and sheet name which I suspect they are not at the moment. Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Jan 5th, 2012,07:29 AM #4 larrygreg New Member Join Date Dec 2011 Posts 46 Re: Compile Error Invalid use of property Thanks for the replies. I changed the file name, so I have a local table that is named. However my problem still exists. The error is occuring at formular1c1 Is there another way to get the value in the cell? Thanks for the help Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Jan 5th, 2012,07:33 AM #5 Colin Legg MrExcel MVPLike totally RAD man Join Date Feb 20