Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

docmd.close makes msaccess crash...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Seppen - 14 Nov 2006 23:33 GMT
Hi,  

With the execution of following sub in a global module, msaccess crashes:
The goal is to delete all tabcontrols of a form and save the design of the
form.
What goes wrong?

(msaccess versie 2002, SP3)
(in the eventviewer I see event 1000 & 1001: Faulting application
msaccess.exe, version 10.0.6771.0, faulting module msaccess.exe, version
10.0.6771.0, fault address 0x00079bbb.)

Use of the sub is as follows

verwijdertabs "form1"

This is the sub:

Public Sub verwijdertabs(formke As String)

   Dim frm As Form
   Dim ctltabset As Control
   DoCmd.OpenForm formke, acDesign
   Set frm = Forms(formke)
   
   For Each ctltabset In frm.Controls
       If ctltabset.ControlType = 123 Then
           DeleteControl frm.Name, ctltabset.Name
       End If
   Next
   
   DoCmd.Close acForm, formke, acSaveYes

End Sub
Alex Dybenko - 15 Nov 2006 12:15 GMT
Hi,
try to set frm = nothing before closing form

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Hi,
>
[quoted text clipped - 30 lines]
>
> End Sub
Seppen - 16 Nov 2006 08:51 GMT
Adjusted sub has the same result: the application crashes:

Public Sub verwijdertabs(formke As String)

   Dim frm As Form
   Dim ctltabset As Control
   DoCmd.OpenForm formke, acDesign
   Set frm = Forms(formke)
   
   For Each ctltabset In frm.Controls
       If ctltabset.ControlType = 123 Then
           DeleteControl frm.Name, ctltabset.Name
       End If
   Next
   
   Set frm = Nothing
   DoCmd.Close acForm, "frmWerkOpvolgingsArbeidsgangen", acSaveYes

End Sub

> Hi,
> try to set frm = nothing before closing form
[quoted text clipped - 33 lines]
> >
> > End Sub
Alex Dybenko - 16 Nov 2006 09:22 GMT
Hi,
could be that you have some code associated with deleted tab control, then I
suggest to delete such code first
you can also try to delete these tab controls manually and then see if your
code still compiled

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Adjusted sub has the same result: the application crashes:
>
[quoted text clipped - 56 lines]
>> >
>> > End Sub
Seppen - 16 Nov 2006 16:41 GMT
Because of the problem I  have, currently there is only code attached to a
"close button" on the form, so that nothing else can be the cause of this
problem.  The only item on the form for the moment is the close button.  With
another peace of code I am filling up the form with a tab-element with a few
pages (code attaced) It might thus be that the error I receive is due the
this bit of code?

The goal of this form is to create as much tabs as I have rec's in a
particular table.
Before adding pages, I first clear out all pages / tabelements.
The sub is thus used in a peace of code as following:

verwijdertabs "form1"
maakpaginas "form1", "subformame", 3

this is the sub:

Public Sub maakpaginas(formke As String, subformke As String, amount As Long)
   Dim i As Integer
   Dim frm As Form
   Dim aantal As Long
   Dim sjek As Boolean
   Dim ctltabset As Control, ctlpage As Control, ctlSub As Control,
ctlCheck As Control, ctlCheckLabel As Control, ctlCmd As Control
   DoCmd.OpenForm formke, acDesign
   Set frm = Forms(formke)
   

   Set ctltabset = CreateControl(frm.Name, acTabCtl, acDetail, , , 500,
500, 9100, 6100)
   ctltabset.Pages(0).Visible = False
   ctltabset.Pages(1).Visible = False
   For i = 0 To amount - 1
       Set ctlpage = CreateControl(frm.Name, acPage, , ctltabset.Name)
       ctlpage.Caption = "pagina" & i
       Set ctlSub = CreateControl(frm.Name, acSubform, , ctlpage.Name, ,
234, 1500, 9000, 4536)
       ctlSub.SourceObject = subformke
       Set ctlCheck = CreateControl(frm.Name, acCheckBox, , ctlpage.Name, ,
234, 1000)
       Set ctlCheckLabel = CreateControl(frm.Name, acLabel, , ctlpage.Name,
, 500, 970, 4500, 250)
       ctlCheckLabel.Caption = "Afgewerkt"
       Set ctlCmd = CreateControl(frm.Name, acCommandButton, ,
ctlpage.Name, , 2500, 800, 6770, 450)
       ctlCmd.Caption = "Maak registratie"
       ctltabset.Left = 200
       ctltabset.Top = 200
       ctltabset.Width = 9100
       Set ctlpage = Nothing
       Set ctlSub = Nothing
       Set ctlCheck = Nothing
       Set ctlCheckLabel = Nothing
       Set ctlCmd = Nothing
   Next i
   Set ctltabset = Nothing
   Set frm = Nothing
   
   DoCmd.Close acForm, formke, acSaveYes
end sub

thanks for helping out here!

> Hi,
> could be that you have some code associated with deleted tab control, then I
[quoted text clipped - 62 lines]
> >> >
> >> > End Sub
Alex Dybenko - 16 Nov 2006 20:00 GMT
Hi,
perhaps you can use a following workaround - instead of delete all tabs you
can make a "template" form without tabs, then copy it into a new form and
then insert tabs using maakpaginas

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Because of the problem I  have, currently there is only code attached to a
> "close button" on the form, so that nothing else can be the cause of this
[quoted text clipped - 132 lines]
>> >> >
>> >> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.