Re: docmd.close makes msaccess crash...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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

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

"Seppen" <Seppen@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:925CA6EC-062A-40DC-9195-CC9ABAA08F98@xxxxxxxxxxxxxxxx
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!

"Alex Dybenko" wrote:

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

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

"Seppen" <Seppen@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6DE5FF6A-C32C-450E-8835-D3E326804697@xxxxxxxxxxxxxxxx
> 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
>
> "Alex Dybenko" wrote:
>
>> Hi,
>> try to set frm = nothing before closing form
>>
>> -- >> Best regards,
>> ___________
>> Alex Dybenko (MVP)
>> http://alexdyb.blogspot.com
>> http://www.PointLtd.com
>>
>> "Seppen" <Seppen@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:73CA717A-C76A-4765-99FF-0F24162039E1@xxxxxxxxxxxxxxxx
>> > 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
>> >
>>
>>



.



Relevant Pages

  • Re: BringToFront
    ... Leban?s Access Rotate Text control 2, but I will come back to that later. ... Dim MouseXStart As Integer, MouseYStart As Integer ... Sub SaveCtlPosition ... Private Sub Angle_AfterUpdate ...
    (comp.databases.ms-access)
  • Re: BringToFront
    ... Leban?s Access Rotate Text control 2, but I will come back to that later. ... Dim MouseXStart As Integer, MouseYStart As Integer ... Sub SaveCtlPosition ... Private Sub Angle_AfterUpdate ...
    (comp.databases.ms-access)
  • Re: Property Page is not loaded on Vista
    ... With managed code you don't have to have a separate OCX for the property page, an OCX is an ActiveX control, that's how it's done in unmanaged code. ... if you aren't using any special controls on your property page user control and not compiling a separate unmanaged OCX then those usual causes don't apply obviously. ... Public Sub ApplyImplements ... Dim userControlType As Type = GetType ...
    (microsoft.public.outlook.program_vba)
  • Re: Selecting multiple tabs in VB
    ... Dim ws As Object, i As Long, arr ... For Each ws In Sheets ... End Sub ... to the left would work if I knew how many tabs would be printed, ...
    (microsoft.public.excel.programming)
  • Re: Colour alternating tabs?
    ... Private Sub Workbook_NewSheet ... ' Every time a new worksheet is added, ... Dim wks As Worksheet ... 2nd tabs their own colours. ...
    (microsoft.public.excel.programming)