Duplicate Option statement

G

Guest

I am trying to write code for the Activate event of a form. I create the
Activate event as usual. It looks like this:

Private Sub Form_Activate()

End Sub

As you can see, there's nothing in the event yet. When I try to open the
form, I get the following message:

The expression On Activate you entered as the event property setting
produced the following error: Duplicate Option statement.
* The expression may not result in the name of a macro, the name of a
user-defined fuction, or [Event Procedure].
* There may have been an error evaluating the function, event or macro.

If I delete the above code, the form opens normally. The same error occurs,
with slightly different wording, when I try to code FormOpen or FormLoad
events instead of FormActivate.

I have tried moving all code and objects to a new form -- the same thing
happens.

I have tried repairing and compacting -- the same thing happens.

I have tried opening a new database and moving all code and objects -- no
dice.

Any ideas? TIA!!
 
A

Andrew Backer

What does the property sheet for the form look like? Does it say
[Event Procedure], or do you yave an =[subname] or something else in
there?

It says 'duplicate option statement', so what do you have at the top of
the code behind? Look for something like :

Option Compare Database
Option Compare Database

or
Option Explicit
Option Explicit

Not in
 
G

Guest

The property sheet just says [Event Procedure]. There are no duplicates, as
far as I can see, and I've looked very hard. No duplicate procedure names,
no duplicate labels, no duplicate objects of any kind.
 
A

Andrew Backer

Is there a lot of code that is sensitive on the page? If not, could you
paste the code-behind of that form?

What happens if you try to compile the database (in vb view
"debug->compile"), and also what happens if you put some code in the
procedure, like a messagebox.

-- andrew
 
G

Guest

Here it is; thanks for your help!

-----------------------------------------------------------

Option Compare Database

Private sub Form_Activate()

End Sub

Private Sub cmbRpt_AfterUpdate()

txtNew.Enabled = False
txtName = DLookup("[rpt_run_name]", "dbo_reports", "rpt_id = " &
cmbRpt.Value)
txtParam = DLookup("[rpt_selection_name]", "dbo_reports", "rpt_id = " &
cmbRpt.Value)
If IsNull(txtParam.Value) Then txtParam.Value = "NULL"
txtTemplate = DLookup("[rpt_template_name]", "dbo_reports", "rpt_id = "
& cmbRpt.Value)
If IsNull(txtTemplate.Value) Or Trim(txtTemplate.Value) = "" Then
txtTemplate.Value = "NULL"
lstProgram = DLookup("[program_id]", "dbo_reports", "rpt_id = " &
cmbRpt.Value)
lstCategory = DLookup("[category]", "dbo_report_category", "rpt_id = " &
cmbRpt.Value)
lstLetterType = DLookup("[rpt_letter_type]", "dbo_reports", "rpt_id = "
& cmbRpt.Value)
If IsNull(lstLetterType.Value) Then lstLetterType.Value = " "

End Sub

Private Sub cmdExit_Click()

On Error GoTo Err_cmdExit_Click

DoCmd.Close

Exit_cmdExit_Click:
Exit Sub

Err_cmdExit_Click:
MsgBox Err.Description
Resume Exit_cmdExit_Click

End Sub

Private Sub cmdEdit_Click()

On Error GoTo Err_cmdEdit_Click

Exit_cmdEdit_Click:
Exit Sub

Err_cmdEdit_Click:
MsgBox Err.Description
Resume Exit_cmdEdit_Click

End Sub

Private Sub cmdNew_Click()
On Error GoTo Err_cmdNew_Click

DoCmd.GoToRecord , , acNewRec

Exit_cmdNew_Click:
Exit Sub

Err_cmdNew_Click:
MsgBox Err.Description
Resume Exit_cmdNew_Click

End Sub
 
G

Guest

Hate to tell you this, but it was so simple -- I removed the

DoCmd.GoToRecord , , acNewRec

and it all works. The form's "Record Source" property was blank, and
evidently this was enough to confuse things, even though the command was
never called. I had just used the wizard to insert all the other code for
me, then didn't remove that line of code.

I'm really guessing, because I've been removing code one line at a time, and
this is the line that did the trick.

Still no real answer ... ??? I'd love to hear your insight, if you have time.
 
P

Paul Overway

You might need to decompile. It sounds like the project is corrupt.

msaccess.exe /decompile "path to your mdb"
 
A

Andrew Backer

Yeah, I agree with the decompile. I have to do it all the now that my
project is huge (and because I am bad and edit it in debug mode.)

As for specifically what was wrong, I have no idea. The error you got
is one that usually means you have the same option statement at the top
twice, sorry.

- Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top