Expected end of statement
The Expected: end of statement message is another common (and rarely helpful) compile error. Once again, all the message is telling you is that you have some sort of syntactical error in the statement. In Figure 12-6, the string literal "MyForm" at the end of the statement is highlighted, but it tells only you that the compiler got lost at that point.
Figure 12-6:
Expected: end of statement compile error.
|
12ChapExamples - Modulel (Code) | ||||
|
J (General) |
» | Sample |
¿1 | ||
|
Option Coutpace Database |
- | |||
|
Public Sub Sample () | ||||
|
Dim Answer As Integer DoCmd,OpenForm "HyForm" | ||||
|
Microsoft Visual Basic | ||||
|
End Sub |
Compile error: | |||
|
Expected : end of statement | ||||
|
OK 1 Help |
• | |||
|
= Jj-1 |
_l | |||
The real problem with the statement shown in Figure 12-6 is the comma between DoCmd and OpenForm. The correct syntax for using the DoCmd object is
DoCmd.method...
where a period — not a comma — appears between the first two words. The fix for the problem is to replace that comma with a period:
DoCmd.OpenForm "MyForm"
Post a comment