Code doesn't work but marcro does

  • Thread starter Thread starter Barry
  • Start date Start date
B

Barry

Hello,

I have an application that opens a form using VBA which I
converted from a macro. It was working just fine, but
now for some reason, it doesn't - when I try to open the
form I get my error message. However, when I put the
macro back on the button, the form opens normally, so I
guess the problem is with the code (which compiles
properly). But the code was converted from a macro that
works, so I'm left scratching my head as to what the
problem is. Can someone explain to me what's happening
and help me solve this? Thanks in advance to anyone who
replies.
 
Sorry... Here's the code. The user selects one of two
options, and the proper form opens. Thanks very much for
your help.

Private Sub OpEntSl_Click()
On Error GoTo OpEntSl_Click_Err

DoCmd.Close acForm, "fm_EntSelect3"
If (SelectEntitle = 1) Then
' Open Entitlement Definition1 form
DoCmd.OpenForm "fm_EntHist1",
acNormal, "", "[EENo]=[Forms]![fm_EEMaster]![EENo]", ,
acNormal
DoCmd.GoToControl "[ViewDetail]"
Forms!fm_EntHist1!Combo16.Enabled = False
End If
If (SelectEntitle = 2) Then
' Open Entitlement Definition2 form
DoCmd.OpenForm "fm_EntHist2",
acNormal, "", "[EENo]=[Forms]![fm_EEMaster]![EENo]", ,
acNormal
DoCmd.GoToControl "[ViewDet]"
Forms!fm_EntHist2!Combo15.Enabled = False
End If


OpEntSl_Click_Exit:
Exit Sub

OpEntSl_Click_Err:
MsgBox "No data", 0, "Argo"
Error$
Resume OpEntSl_Click_Exit

End Sub
 
Hello,

I have an application that opens a form using VBA which I
converted from a macro. It was working just fine, but
now for some reason, it doesn't - when I try to open the
form I get my error message. However, when I put the
macro back on the button, the form opens normally, so I
guess the problem is with the code (which compiles
properly). But the code was converted from a macro that
works, so I'm left scratching my head as to what the
problem is. Can someone explain to me what's happening
and help me solve this? Thanks in advance to anyone who
replies.

Care to post the code? I can't see it from here, so it's a bit
difficult to debug!

Note that the event property on the form design should show

[Event Procedure]

rather than the name of the macro.
 
Back
Top