Database Locks when Form is Opened

G

Guest

Hello,
I have a strange problem with one form (frm_ReportDialog) in my 2K database. When the form is called to open via a cmd button, the database freezes. This is the only form with this problem. However, this does not occur on my PC (the developing PC), where it works perfectly. This only occurs when the db is moved to another location.

Frm_ReportDialog is opened by an option button on the frm_MainSwitchboard via the OnClick event with a macro. I checked to see if the macro was incorrect by changing the form it was to open, and it opened the other form with no problems. I have therefore decided that it must be frm_ReportDialog itself.

Frm_ReportDialog has 4 option buttons within an option group. There are 3 buttons on the form as well: cmdPreview, cmdPrint, and cmdClose. I had these cmd buttons using macros, but I decided to convert them into VBA (with the wizard) thinking that may be the problem. However, the the cmdPreview and cmdPrint are not working with the new VBA code/event procedures. (CmdClose is working fine.)

Here is the code:
Private Sub CmdPreview_Click()
With CodeContextObject
' Closes Report Dialog box
DoCmd.Close acForm, "frm_ReportDialog"
If (.optgrpRptDialog = 1) Then
' Opens Sys Analyst Coordination Document report
DoCmd.OpenForm "frm_LINDialog", acNormal, "", "", acEdit, acNormal
End If
If (.optgrpRptDialog = 2) Then
' Opens LIN-System Date report
DoCmd.OpenReport "rpt_LIN_Dates", acPreview, "", ""
End If
If (.optgrpRptDialog = 3) Then
' Opens LIN with System Analyst report
DoCmd.OpenReport "rpt_LIN_SystemAnalyst", acPreview, "", ""
End If
If (.optgrpRptDialog = 4) Then
' Opens LIN grouped by System Analyst report
DoCmd.OpenReport "rpt_SystemAnalystLIN", acPreview, "", ""
End If
End With
End Sub

Private Sub CmdPrint_Click()
With CodeContextObject
' Closes Report Dialog box
DoCmd.Close acForm, "frm_ReportDialog"
If (.optgrpRptDialog = 1) Then
' Opens Sys Analyst Coordination Document report in print
DoCmd.OpenForm "frm_LINDialog", acNormal, "", "", acEdit, acNormal
End If
If (.optgrpRptDialog = 2) Then
' Opens LIN-System Date report in print
DoCmd.OpenReport "rpt_LIN_Dates", acNormal, "", ""
End If
If (.optgrpRptDialog = 3) Then
' Opens LIN with System Analyst report in print
DoCmd.OpenReport "rpt_LIN_SystemAnalyst", acNormal, "", ""
End If
If (.optgrpRptDialog = 4) Then
' Opens LIN grouped by System Analyst report in print
DoCmd.OpenReport "rpt_SystemAnalystLIN", acNormal, "", ""
End If
End With
End Sub

I am getting this error: "Application-defined or object-defined error." I am new to VBA and not familier with "CodeContextObject" and do not know if that may be the problem.

Does anyone have an suggestions on how I may resolve this problem? Please let me know if you need more information.

Thank you very much,
Mary :)
 
G

GVaught

Always recompile a database when moving to another machine as that machine
may not have the same 'reference' settings as your development machine.

--
G Vaught

MaryF said:
Hello,
I have a strange problem with one form (frm_ReportDialog) in my 2K
database. When the form is called to open via a cmd button, the database
freezes. This is the only form with this problem. However, this does not
occur on my PC (the developing PC), where it works perfectly. This only
occurs when the db is moved to another location.
Frm_ReportDialog is opened by an option button on the frm_MainSwitchboard
via the OnClick event with a macro. I checked to see if the macro was
incorrect by changing the form it was to open, and it opened the other form
with no problems. I have therefore decided that it must be frm_ReportDialog
itself.
Frm_ReportDialog has 4 option buttons within an option group. There are 3
buttons on the form as well: cmdPreview, cmdPrint, and cmdClose. I had
these cmd buttons using macros, but I decided to convert them into VBA (with
the wizard) thinking that may be the problem. However, the the cmdPreview
and cmdPrint are not working with the new VBA code/event procedures.
(CmdClose is working fine.)
Here is the code:
Private Sub CmdPreview_Click()
With CodeContextObject
' Closes Report Dialog box
DoCmd.Close acForm, "frm_ReportDialog"
If (.optgrpRptDialog = 1) Then
' Opens Sys Analyst Coordination Document report
DoCmd.OpenForm "frm_LINDialog", acNormal, "", "", acEdit, acNormal
End If
If (.optgrpRptDialog = 2) Then
' Opens LIN-System Date report
DoCmd.OpenReport "rpt_LIN_Dates", acPreview, "", ""
End If
If (.optgrpRptDialog = 3) Then
' Opens LIN with System Analyst report
DoCmd.OpenReport "rpt_LIN_SystemAnalyst", acPreview, "", ""
End If
If (.optgrpRptDialog = 4) Then
' Opens LIN grouped by System Analyst report
DoCmd.OpenReport "rpt_SystemAnalystLIN", acPreview, "", ""
End If
End With
End Sub

Private Sub CmdPrint_Click()
With CodeContextObject
' Closes Report Dialog box
DoCmd.Close acForm, "frm_ReportDialog"
If (.optgrpRptDialog = 1) Then
' Opens Sys Analyst Coordination Document report in print
DoCmd.OpenForm "frm_LINDialog", acNormal, "", "", acEdit, acNormal
End If
If (.optgrpRptDialog = 2) Then
' Opens LIN-System Date report in print
DoCmd.OpenReport "rpt_LIN_Dates", acNormal, "", ""
End If
If (.optgrpRptDialog = 3) Then
' Opens LIN with System Analyst report in print
DoCmd.OpenReport "rpt_LIN_SystemAnalyst", acNormal, "", ""
End If
If (.optgrpRptDialog = 4) Then
' Opens LIN grouped by System Analyst report in print
DoCmd.OpenReport "rpt_SystemAnalystLIN", acNormal, "", ""
End If
End With
End Sub

I am getting this error: "Application-defined or object-defined error."
I am new to VBA and not familier with "CodeContextObject" and do not know if
that may be the problem.
Does anyone have an suggestions on how I may resolve this problem? Please
let me know if you need more information.
 

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