docmd.close makes msaccess crash...

G

Guest

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
 
G

Guest

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
 
G

Guest

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!
 

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