Compile Error Object Required Access
Contents |
Links Social Groups Pictures & Albums Members List Calendar Search Forums Show Threads Show Posts Tag Search Advanced Search Find All Thanked Posts Go to Page... Thread Tools Rate Thread Display Modes 01-16-2004, 10:18 AM #1 swes912 Junior compile error object required excel macro Member Join Date: Jan 2004 Location: denver Posts: 5 Thanks: 0 Thanked 0 Times in
Compile Error Object Required Error In Vba
0 Posts compile error: object required- - - -Help! On a form I am trying to update a table with Month and Year set vba that user chooses. I did a test and know that the date from the form is coming through good. The error I get is a compile error object required on the Set stSQL = "......." Private Sub cmdStartForm_Click() If object required vba (Me![lstMonth].Value = Null) Then MsgBox "Please highlight a Month.", vbOKOnly End If If (Me![lstYear].Value = Null) Then MsgBox "Please highlight a Year.", vbOKOnly End If Dim con As Object Dim rs As Object Dim stSQL As String Dim intOption As Integer Set con = Application.CurrentProject.Connection Set rs = CreateObject("adodb.recordset") Set stSQL = "UPDATE [Basin_Supplemental_Demand]SET [month] = " & Me![lstMonth].Value & ", [year] = " & Me![lstYear].Value & "WHERE bsdID=1;" rs.Open stSQL, con, 1 '1 = adOpenKeyset Thanks for the
Object Variable Or With Block Variable Not Set
help!!!! swes912 View Public Profile Find More Posts by swes912 01-16-2004, 10:31 AM #2 dcx693 Registered User Join Date: Apr 2003 Location: Brooklyn Posts: 3,265 Thanks: 0 Thanked 2 Times in 2 Posts You just have an issue with spaces in your statement before the SET keyword and before the WHERE keyword. Try this: Set stSQL = "UPDATE [Basin_Supplemental_Demand] SET [month] = " & Me![lstMonth].Value & ", [year] = " & Me![lstYear].Value & " WHERE bsdID=1;" The .Value property is the default property for controls. You can shorten the command to this: Set stSQL = "UPDATE [Basin_Supplemental_Demand] SET [month] = " & Me![lstMonth] & ", [year] = " & Me![lstYear] & " WHERE bsdID=1;" dcx693 View Public Profile Find More Posts by dcx693 01-16-2004, 05:15 PM #3 Pat Hartman Super Moderator Join Date: Feb 2002 Location: Stratford,Ct USA Posts: 25,623 Thanks: 12 Thanked 1,042 Times in 990 Posts Me![lstMonth].Value = Null is NOT a valid way to check for nulls. This statement will ALWAYS be false regardless of the value of lstMonth. IsNull(Me.[lstMonth]) Is correct. Read help or search here for further explaination on null. Month and Year are both function names and as such should NEVER be used to name user objects and will occassionally cause errors so if the missing spaces don't fix the problem, I would
Editions: US United States Australia United Kingdom Japan Newsletters Forums Resource Library Tech Pro Free Trial Membership Membership My Profile People Subscriptions My stuff Preferences Send a message Log Out TechRepublic Search GO Topics: CXO Cloud Big Data application-defined or object-defined error Security Innovation Software Data Centers Networking Startups Tech & Work All Topics Sections: Photos Videos compile error in hidden module All Writers Newsletters Forums Resource Library Tech Pro Free Trial Editions: US United States Australia United Kingdom Japan Membership Membership My Profile People Subscriptions My stuff Preferences Send a message Log Out TechRepublic | Forums | Software Software Register Now or Log In to post Welcome back, My Profile Log Out Recent Activity FAQs Guidelines Question 0 Votes http://www.access-programmers.co.uk/forums/showthread.php?t=60381 Locked Getting "Compile Error: Object required" By atorres · 8 years ago I have the follwing VBA code in an Access form to hide and unhide Combobox and Listbox; but I am getting a "Compile Error: Object required." I would appreciate anyone that could look at the code and tell me what I am doing wrong. If I need to post more info, let me know.Public Sub cmbRptName_AfterUpdate()Dim intLvlID As IntegerintLvlID = "Select http://www.techrepublic.com/forums/discussions/getting-compile-error-object-required/ LevelID From tblReports " & _ "WHERE ReportID = " & cmbRptName.ValueIf IsNull(intLvlID) Then Me.cmbRptName.Visible = True Me.cmbSup.Visible = False Me.lstAssociate.Visible = FalseIfElse intLvlID = 1 Me.cmbSup.Visible = False Me.lstAssociate.Visible = FalseIfElse intLvlID = 2 Me.cmbSup.Visible = True Me.lstAssociate.Visible = FalseElse Me.cmbSup.Visible = True Me.lstAssociate.Visible = TrueEnd IfSet intLvlID = NothingEnd Sub Share Flag This conversation is currently closed to new comments. 12 total posts (Page 1 of 2) 01 | 02 Next + Follow this Discussion · | Thread display: Collapse - | Expand + All Answers Collapse - Post by Wizard-09 · 8 years ago In reply to Getting "Compile Error: O ... The code in order for anyone to help you out with this, without the code we cant tell were it is going wrong. 0Votes Share Flag Collapse - Set intLvlID = Nothing 'is your problem by Slayer_ · 8 years ago In reply to Getting "Compile Error: O ... int's are primitave data types and don't need to be set to nothing, set nothing is for objects, thus object required 0Votes Share Flag Collapse - Now: Sub or Function not defined by atorres · 8 years ago In reply to Set intLvlID = Nothing 'i ... Thanks for the reply. I now getting a new error: Sub or Function not define
soon) Ruby (coming soon) Getting Started Code Samples Resources Patterns and Practices App Registration Tool Events Podcasts Training https://msdn.microsoft.com/en-us/library/office/gg251554.aspx API Sandbox Videos Documentation Office Add-ins Office Add-in Availability Office Add-ins Changelog Microsoft Graph API Office 365 Connectors Office 365 REST APIs SharePoint Add-ins Office UI Fabric Submit to the Office Store All Documentation https://www.yammer.com/ http://feeds.feedburner.com/office/fmNx Office VBA language reference Visual Basic language reference Error Messages Error Messages Object required (Error 424) compile error Object required (Error 424) Object required (Error 424) #Else clause must be preceded by a matching #If #Else If, #Else, or #End If must be preceded by a matching #If #ElseIf must be preceded by a matching #If or #ElseIf and followed by an #ElseIf, #Else, or #End If