473,383 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

error: Expected End Sub

44
Hi,

Im getting this error mesage, for the below code. I have tried to add END Sub at the end but still didnt work

Any ideas?
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command45_Enter()
  2. Function updateList()
  3. 're-create query stuff
  4. Me.lstName.ControlSource = "Form_hours worked"
  5. Me.lstName.Requery
  6. End Function
Mar 5 '09 #1
11 8511
Dan2kx
365 100+
because you open with "sub"
and end with "function"
They should be the same, one or the other
Mar 5 '09 #2
DavidPT
44
Yeah i tried End Sub.

So what are you suggesting
Mar 5 '09 #3
Dan2kx
365 100+
replace end function with end sub
Mar 5 '09 #4
DavidPT
44
@Dan2kx
Just tried this still getting the same error message
Mar 5 '09 #5
Dan2kx
365 100+
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command45_Enter()
  2. 're-create query stuff
  3. Me.lstName.ControlSource = "Form_hours worked"
  4. Me.lstName.Requery
  5. End Sub
You tried that?

or

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command45_Enter()
  2. call updateList()
  3. End Sub
Expand|Select|Wrap|Line Numbers
  1. Function updateList()
  2. 're-create query stuff
  3. Me.lstName.ControlSource = "Form_hours worked"
  4. Me.lstName.Requery
  5. End Function 
Mar 5 '09 #6
DavidPT
44
Tried all of the above didnt work. If i change the code to much i think it will effect my access form.
Mar 5 '09 #7
smartchap
236 100+
I think you may try the following code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command45_Enter()
  2. updateList()
  3. 're-create query stuff
  4. Me.lstName.ControlSource = "Form_hours worked"
  5. Me.lstName.Requery
  6. End Sub
where I assume that updateList() is a function defined by you somewhere else in the code.
Mar 5 '09 #8
missinglinq
3,532 Expert 2GB
@DavidPT
We're all guessing, of course, without seeing all of the pertinent code, but you've apparently Copy and Pasted a function in the middle of a sub, which you can't do! Somewhere below the code you posted I suspect you have an End Sub, possibly with code preceding it, that should be closing Sub Command45_Enter().

My advice would be to delete all the code you posted, and look for the stray, unmatched, End Sub , delete it, and start over again.

Linq ;0)>
Mar 5 '09 #9
DavidPT
44
Thanks for the replys this is the whole code
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command45_Click()
  2. On Error GoTo Err_Command45_Click
  3.  
  4.  
  5.     DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
  6.  
  7. Exit_Command45_Click:
  8.     Exit Sub
  9.  
  10. Err_Command45_Click:
  11.     MsgBox Err.Description
  12.     Resume Exit_Command45_Click
  13.  
  14. End Sub
  15.  
  16. Private Sub Command45_Enter()
  17. Function updateList()
  18. 're-create query stuff
  19. Me.lstName.ControlSource = "Form_hours worked"
  20. Me.lstName.Requery
  21. End Function
Mar 5 '09 #10
NeoPa
32,556 Expert Mod 16PB
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it.

Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use the tags in future.

Administrator.

PS. Tags are done as matching pairs where the opening one is surrounded by [...] and the closing one by [/...]. A set of buttons is available for ease of use in the Standard Editor (Not the Basic Editor). The one for the [ CODE ] tags has a hash (#) on it. You can choose which editor to use in your profile options (Look near the bottom of the page).
Mar 5 '09 #11
NeoPa
32,556 Expert Mod 16PB
David, You need an End Sub line after line #16 and before trying to start a new procedure in line #17.

After the explanations already posted I fail to see why you should need to post this here for someone to do for you. It's fair enough if you simply can't understand what's being said, but you make no mention of that. You simply post the code for someone to tell you the precise answer. I have to say I can't see that attitude winning you many friends here.
Mar 5 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
5
by: andy.herrera | last post by:
I'm getting this Error Message. Expected ';' Please Select One: <form name="form1"> <<------------ Error is here. <select name="selectTrans" onChange="If (this.value == 'checkout')...
1
by: Franko | last post by:
I get the following error. Please help c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,38): error CS1001: Identifier expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,52): error...
1
by: Franko | last post by:
I get the following error. Please help c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,38): error CS1001: Identifier expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,52): error...
1
by: Carlos Kim via DotNetMonster.com | last post by:
Compiler Error Message: CS1026: ) expected Source Error: Line 12: <body MS_POSITIONING="GridLayout"> Line 13: <form id="Form1" method="post" runat="server"> Line 14:...
5
by: cranium.2003 | last post by:
hi, Here is my code #include <iostream.h> int main() { cout <<"HI"; return 0; } and using following command to compile a C++ program g++ ex1.cpp -o ex1
3
by: rorni | last post by:
Hi, I'm porting code from Windows to HP-UX 11, compiling with g++. I'm getting a compilation error on the system's debug.h include file, which is included very indirectly through a series of...
2
by: kya2 | last post by:
I am not able to create following store procedure. CREATE PROCEDURE DBSAMBA.InsertDeleteBatch(OUT norows INT ) RESULT SETS 1 LANGUAGE SQL BEGIN part1 DECLARE TOTAL_LEFT INT DEFAULT 0; ...
6
by: samsneelam | last post by:
Hi.. This is samuel, while doing a program, i encountered this problem.. Let me give you clarity regarding my prob.. I am having two files .. one is mpcplib.h it contains the follwing...
3
by: Hill | last post by:
This is an simple map, just an exercise. Who can help me fix this compile issue?Thanks in advance. #include <string> #include <vector> #include <iostream> using std::vector; using std::string;...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.