Ha ha! I had forgotten that one. I used to do it frequently when I had replicated Dbs. The procedure I used was slightly more simple than that ref:
Access - Decompile databases
In ‘Run’ type MSACCESS /decompile.
When Access starts, hold down the shift key (stops auto macros running which would cause normal opening) and select the Db to decompile.
Open Code window and compile Db
Do a compact & repair.
However, it didn't work this time. It did reduce the Db size from 11Mb (after a Compact & Repair) to 6.6 Mb though.
Here is the code that calls that form (frmFunds)
Code: Select all
DoCmd.OpenForm "frmFunds", acNormal
With Forms![frmFunds]
.Filter = "[PolSalesNo]=" & SNo
.FilterOn = True
![txtWhoFor].Value = "Funds for: " & Nz(Me.Parent.Parent![txtFirstName]) & " " & Nz(Me.Parent.Parent![LastName]) & Chr(34)
![txtWhoFor].ControlSource = "=" & Chr(34) & "Funds for: " & Nz(Me.Parent.Parent![txtFirstName]) & " " & Nz(Me.Parent.Parent![LastName]) & Chr(34)
![txtSalesNoChecker] = SNo
If Nz(![txtProduct]) = vbNullString Then
![txtProduct] = Nz(Me![Product])
End If
![txtPolNo] = Nz(Me![Pol no])
' ![txtSalesNo] = SNo 'This creates a record. We want to wait until a FundName is entered
' before a record is created. (txtFundName_AfterUpdate() enters the txtSalesNo.
End With 'Forms![frmFunds]
SetSize 'sets the size of frmFunds to suit the number of records
If blnNoFunds = True Then
'Trigger default val for [Sort]
Forms![frmFunds]![txtSorter].SetFocus
Forms![frmFunds]![txtFocusRecv].SetFocus
End If
The Funtion SetSize:
Code: Select all
Function SetSize()
'Sets size of frmFunds
Dim rsCopyFunds As Recordset, rsFunds As Recordset
Dim SalesNo As Long, NumRecs As Long
Dim MaxDateIn As Date
Dim Ht, Wdth
On Error GoTo Err_SetSize
Forms![frmFunds].TimerInterval = 1000000
SalesNo = Forms![frmFunds]![txtSalesNo]
'There are various 'DateIn's, we want the records that have the latest one
MaxDateIn = DMax("[DateIn]", "tblFunds", "[PolSalesNo] = " & SalesNo)
Set rsFunds = CurrentDb.OpenRecordset("tblFunds", dbOpenDynaset)
rsFunds.Filter = "[PolSalesNo] = " & SalesNo & " AND [DateIn] = #" & Format(MaxDateIn, "mm/dd/yyyy") & "#"
Set rsCopyFunds = rsFunds.OpenRecordset
rsCopyFunds.MoveLast
NumRecs = rsCopyFunds.RecordCount
'DoCmd.MoveSize(Right, Down, Width, Height)
'567 TWIPS per cm
'Header=2.034cm; Detail=0.462cm; Footer=0.423cm; Width=10.307cm
'Header=1153Twips; Footer=240Twips; - Hdr + Ftr = 1393 (change to 2300)
'Detail=262Twips (change to 233); Width=5844Twips (change to 6660)
Ht = 2350 + NumRecs * 233 'Pretty darned close on Office1
If Ht > 5600 Then Ht = 5600
Wdth = 9250
DoCmd.MoveSize , , Wdth, Ht
Exit_SetSize:
Set rsCopyFunds = Nothing: Set rsFunds = Nothing
Exit Function
Err_SetSize:
MsgBox Err.Description
Resume Exit_SetSize
Resume
End Function
The OnOpen code for frmFunds:
Code: Select all
Private Sub Form_Open(Cancel As Integer)
Me.TimerInterval = 500 '1/2 sec
Me.OnTimer = "=CallGetTot()"
Debug.Print Me.TimerInterval; Me.OnTimer
End Sub
The Debug.Print successfully prints the correct values of: 500 & =CallGetTot()
If I set the Me.TimerInterval to 50000, giving me time to open the already opened frmFunds in design mode, those values are 0 and blank. This is so even if I save frmFunds before opening in Design mode.
Maybe someone can see what is causing the problem.