A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Compile Error - Only comments may appear after end sub,...



 
 
Thread Tools Display Modes
  #1  
Old December 19th, 2006, 04:21 PM posted to microsoft.public.access.forms
ChuckW
external usenet poster
 
Posts: 182
Default Compile Error - Only comments may appear after end sub,...

Hello,

I am a novice VBA user and keep getting a compile error in my program. Here
is some of my code. The compile error I get says "Only comments may appear
after End Sub, End Function or End Property". The Me in the line
Me!ClassDate.SetFocus is highlighted in blue with a yellow arrow pointing to
the line Private Sub Command27_Click(). Can someone help?

Thanks,

----------------------------------------------------------------------------------------
Private Sub Command27_Click()
On Error GoTo Err_Command27_Click


DoCmd.Close

Exit_Command27_Click:
Exit Sub

Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click

End Sub

Me!ClassDate.SetFocus
DoCmd.FindRecord Date
Me!ClassDate.SetFocus


End Sub

--
Chuck W
  #2  
Old December 19th, 2006, 05:06 PM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default Compile Error - Only comments may appear after end sub,...

On Tue, 19 Dec 2006 08:21:01 -0800, ChuckW wrote:

Hello,

I am a novice VBA user and keep getting a compile error in my program. Here
is some of my code. The compile error I get says "Only comments may appear
after End Sub, End Function or End Property". The Me in the line
Me!ClassDate.SetFocus is highlighted in blue with a yellow arrow pointing to
the line Private Sub Command27_Click(). Can someone help?

Thanks,

----------------------------------------------------------------------------------------
Private Sub Command27_Click()
On Error GoTo Err_Command27_Click

DoCmd.Close

Exit_Command27_Click:
Exit Sub

Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click

End Sub ****

Me!ClassDate.SetFocus
DoCmd.FindRecord Date
Me!ClassDate.SetFocus

End Sub ****


You have 2 End Subs in one sub procedure.
I've marked them with asterisks.

Everything after the first end sub is misplaced.

I have no idea what you want to do with those extra lines, as it
appears you are closing the form. You can't set focus to a control on
the form when it is closed.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:10 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.