I want to create a form which has a "grid" of thumbnail pictures. I had the code working by designing the form and placing 36 image boxes in a 6x6 grid. But the number of pictures has increased (current total is 79) and the user wants to see them all on one page. So I have been "hacking" away with minimal success at trying to add the image boxes dynamically. At one stage the image grid did appear, then I got memory full, a further iteration I added click events to the code - and the code module looks reasonable. But now having (apparently) added all the new controls and code when I try and save the form the whole thing just disappears (the code exits completely with no error message.
This is the startup form
Code:Private Sub Form_Load() DeclareColours GAKELoad GAKECreateGrid DoCmd.Close acForm, Me.Name DoCmd.OpenForm "GAKE-Dahlia" End Sub Private Sub GAKECreateGrid() Dim tempfile As String Dim wThisCount As Integer Dim bPrimePic As Boolean Dim wPrimePic As String 'imgBox.Visible = False 'lblCurPos.Caption = "" bPrimePic = False 'cmdPrime.Visible = False Dim wT As Integer Dim wW As Integer Dim wH As Integer Dim wL As Integer Dim wName As String Dim wMDL As Module 'tempfile = "C:\G-Apps\GAKE-2022\GAKE.txt" Set db = CurrentDb() Set rs = db.OpenRecordset("Dahlias", dbOpenDynaset) rs.MoveLast GAKENumPics = rs.RecordCount '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ DoCmd.OpenForm "GAKE-Dahlia", acDesign, , , , acHidden Set wMDL = Forms![GAKE-Dahlia].Module '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@ Now try and create the required number of pictures dynamically '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ wPics = 6 wPicd = GAKENumPics / wPics If GAKENumPics Mod wPics <> 0 Then wPicd = wPicd + 1 End If '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@ If this is not the first time then we must delete the controls '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ For i = 1 To wPicd For j = 1 To wPics wName = "i" & i & j For Each wctl In Forms![GAKE-Dahlia].Controls If wctl.Name = wName Then DeleteControl "GAKE-Dahlia", wName End If Next Next Next rs.MoveFirst For i = 1 To wPicd For j = 1 To wPics wT = wPicT + ((i - 1) * (wPicH / wPics)) wH = wPicH / wPics wW = wPicW / wPics wL = wPicL + ((j - 1) * (wPicW / wPics)) wName = "i" & i & j Set ctlimage = CreateControl("GAKE-Dahlia", acImage, , , , wL, wT, wW, wH) ctlimage.Name = wName ctlimage.Picture = GAKEPictures & rs!DahliaPicture & ".jpg" ctlimage.Tag = wCurPos & "£" & GAKEPictures & rs!DahliaPicture & ".jpg" & "$" & rs!DahliaName ctlimage.Visible = True ctlimage.Properties.Item("OnClick") = "[Event Procedure]" strcode = "Private Sub " & wName & "_Click()" & vbCr _ & "BigImage (" & wName & ".Tag)" & vbCr _ & "End Sub" wMDL.InsertText strcode wCurPos = wCurPos + 1 rs.MoveNext If rs.EOF Then GoTo wOut End If Next Next wOut: 'DoCmd.OutputTo acOutputModule, wMDL, acFormatTXT, tempfile 'Set wMDL = Nothing rs.Close Set rs = Nothing Set db = Nothing MsgBox "closing" DoCmd.Close acForm, "GAKE-Dahlia", acSaveYes '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@ This next line is never executed - it just crashes silently '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MsgBox "closed" End Sub