Form Detail Disappears

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form called from a procedure that opens the form and immediately
calls another procedure that sets the visibility of several controls to false.

When the form then displays the detail section flickers with the first row
of data and then disappears entirely. Information set in labels in the header
appear correctly whereas information in several textboxes in the header set
with code in Form_Load from OpenArgs also disappears.

If I leave the form, go to the database window and open it from there all
the data that should show appears correctly. The form's record source is a
simple table in the database.

I have worked through all code involved in populating the table and find
nothing wrong. (The entire process has worked previously and I thought I
might have changed something)
 
I have a form called from a procedure that opens the form and immediately
calls another procedure that sets the visibility of several controls to false.

When the form then displays the detail section flickers with the first row
of data and then disappears entirely. Information set in labels in the header
appear correctly whereas information in several textboxes in the header set
with code in Form_Load from OpenArgs also disappears.

If I leave the form, go to the database window and open it from there all
the data that should show appears correctly. The form's record source is a
simple table in the database.

I have worked through all code involved in populating the table and find
nothing wrong. (The entire process has worked previously and I thought I
might have changed something)

<shrug> There's evidently something wrong with the code. Since I can't
see the code I can't even begin to guess what.

The symptom - a blank form - arises when the form's Recordset is not
updateable (or the form does not allow updates), and the recordset is
also empty. You say that's not the case, but doublecheck (the Filter
might be set for instance).

John W. Vinson[MVP]
 
The code commences with a lengthy portion that I am skipping here that
populates a table in the Access front-end. (The main tables are linked from a
SQL Server db). The form in question has as its record source this table
populated from the beginning of procedure. The end of the procedure sets up
which of 2 forms will be displayed (the second of which is not the problem).
With the first form this code opens the form and calls 2 other procedures.
These 2 procedures populate some header titling information and set which
controls on the form will be visible. I have tried the code without
activating either the 2nd or 3rd procedure with no more success. In all cases
what occurs is somehow the form by the time it should be displayed supposedly
does not have a record source. Yet when I close it, go to the database window
and open it it displays exactly as it should.

I have listed the code as follows: the main code 1st (As I mentioned I left
of the beginning that populates the table that is the forms record source.)
The 2nd and the 3rd as called by the first code. The form in question is
named 'frmTestSelectionSpec" and is referred to in the code as strNextForm

THE MAIN CODE
If strAddOrEdit <> "Save" Then
For x = 0 To 2
If aryHasTestSources(x) = True Then
Debug.Print "2. aryHasTestSources(" & x & ") = " &
aryHasTestSources(x)
aryScreenSetup = Array(strFrom, lngSlctdTRID, lngTRNmbr,
aryTestSourceIDs(0), aryTestSources(0), _
aryTestMapIDs(0), aryColCount(0), aryTestSourceIDs(1),
aryTestSources(1), aryTestMapIDs(1), _
aryColCount(1), aryHasTestSources(2), strTestCatAndComp)
strSlctdTempTable = aryTempTables(x)

If x < 2 Then
blnTestingCreated = True
strNextForm = "frmTestSelectionSpec"
lngChkPt = 27

DoCmd.OpenForm strNextForm
Forms(strNextForm).RecordSource = strSlctdTempTable
Call SetMapDisplay(aryColCount(x), strSlctdTempTable)
Call SetMapHeaderInfo(aryScreenSetup, strSlctdTempTable,
strNextForm)
If strAddOrEdit = "Add" Or strAddOrEdit = "Edit" Or
strAddOrEdit = "NewByCopy" Then
Call UnlockForEdit(strNextForm, False, aryColCount(x))
ElseIf strAddOrEdit = "View" Then
Call UnlockForEdit(strNextForm, True, aryColCount(x))
End If
lngChkPt = 28
'-- Lock the map screen when a primary spec with full
phase is displayed
If lngPartialFullPhase = 2 And x = 0 Then
Call UnlockForEdit(strNextForm, True, aryColCount(x))
End If
'-- For a new test load for a primary spec in full
phase mark all tests as selected
If strAddOrEdit = "Add" Or strAddOrEdit = "NewByCopy" Then
If lngPartialFullPhase = 2 And x = 0 Then
Set rstFullPhaseSet = Forms(strNextForm).Recordset
With rstFullPhaseSet
.MoveFirst
Do Until .EOF
.Edit
!TestLegSlctd = -1
.Update
Call
Forms(strNextForm).Form.chkLeg_AfterUpdate
.MoveNext
Loop
End With
rstFullPhaseSet.Close
End If
End If
Application.Echo True
GoTo JumpToShowTests
ElseIf x = 2 Then
blnTestingCreated = True
DoCmd.OpenForm "frmTestSelectionSpecial", , , , , ,
strNextScreenSetup
Application.Echo True
End If
End If
Next x
End If

JumpToShowTests:

2ND PROCEDURE
Sub SetMapDisplay(lngMaxNmbrCols As Long, strRecordSourceToUse As String)

Dim x As Integer
Dim strFormToUse As String
Dim strSlctControl As String

strFormToUse = "frmTestSelectionSpec"
' Forms(strFormToUse).RecordSource = ""
' Debug.Print "strRecordSourceToUse = " & strRecordSourceToUse
' Forms(strFormToUse).RecordSource = strRecordSourceToUse

For x = 65 To 84
strSlctControl = "lblCol" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
strSlctControl = "chk" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
strSlctControl = "txtQty" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
strSlctControl = "chkDVPR" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
strSlctControl = "txtTestNmbrYes" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
strSlctControl = "txtTestNmbrNo" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
strSlctControl = "txtTestNameYes" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
strSlctControl = "txtTestNameNo" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
strSlctControl = "txtIsTest" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
strSlctControl = "txtDVPR" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
strSlctControl = "txtTest" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
strSlctControl = "box" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = True
Next x

For x = 84 To 65 + lngMaxNmbrCols Step -1
strSlctControl = "lblCol" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
strSlctControl = "chk" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
strSlctControl = "txtQty" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
strSlctControl = "chkDVPR" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
strSlctControl = "txtTestNmbrYes" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
strSlctControl = "txtTestNmbrNo" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
strSlctControl = "txtTestNameYes" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
strSlctControl = "txtTestNameNo" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
strSlctControl = "txtIsTest" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
strSlctControl = "txtDVPR" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
strSlctControl = "txtTest" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
strSlctControl = "box" & Chr(x)
Forms(strFormToUse).Controls(strSlctControl).Visible = False
Next x

End Sub

3RD PROCEDURE
Sub SetMapHeaderInfo(aryScreenSetupToUse, strRecordSourceToUse As String,
strNextFormToUse As String)

Dim aryScreenFactors
Dim x As Integer

strMapListPrevious = aryScreenSetupToUse(0)
lngMapListTRID = aryScreenSetupToUse(1)
lngTRNmbr = aryScreenSetupToUse(2)
lngMapListSpecID = aryScreenSetupToUse(3)
strSpecNmbr = aryScreenSetupToUse(4)
lngSpecMapID = aryScreenSetupToUse(5)
lngSpecColNmbr = aryScreenSetupToUse(6)
lngSecondarySpecID = aryScreenSetupToUse(7)
str2ndSpecNmbr = aryScreenSetupToUse(8)
lng2ndSpecMapID = aryScreenSetupToUse(9)
lng2ndSpecColNmbr = aryScreenSetupToUse(10)
blnHasSpecialTesting = aryScreenSetupToUse(11)
strCatAndComp = aryScreenSetupToUse(12)

Forms(strNextFormToUse)!txtTestRequestID = lngMapListTRID
Forms(strNextFormToUse)!txtTestRequestNmbr = lngTRNmbr
Forms(strNextFormToUse)!txtSpecID = lngMapListSpecID
Forms(strNextFormToUse)!txtSecondarySpecID = lngSecondarySpecID
Forms(strNextFormToUse)!txtHasSpecialTesting = blnHasSpecialTesting

If lngSecondarySpecID = 0 Or IsNull(lngSecondarySpecID) Then
Forms(strNextFormToUse)!cmdSecondarySpecTests.Enabled = False
ElseIf lngSecondarySpecID > 0 Then
Forms(strNextFormToUse)!cmdSecondarySpecTests.Enabled = True
End If
If blnHasSpecialTesting = False Then
Forms(strNextFormToUse)!cmdSpecialTests.Enabled = False
ElseIf blnHasSpecialTesting = True Then
Forms(strNextFormToUse)!cmdSpecialTests.Enabled = True
End If

lngNmbrColsNow = lngSpecColNmbr

If strMapListPrevious = "frmAddNewTR" Then
Forms(strNextFormToUse)!lblFormTitle.Caption = "Tests for " &
strSpecNmbr & " for New TR"
' ElseIf blnIsNewByCopy = False Then
' Forms(strNextFormToUse)!lblFormTitle.Caption = "Tests for " &
strSpecNmbr & " for New TR"
Else
Forms(strNextFormToUse)!lblFormTitle.Caption = "Tests for " &
strSpecNmbr & " for TR # " & Format(lngTRNmbr, "000000")
End If

' If blnIsEdit = True Then
' Call SetForEdit
' End If

End Sub

Thank you for your quick response. It was appreciated.
 
Thank you John for your advice. I solved the problem by separating the tasks
of populating the table from displaying the results.

Sorry I didn't get a chance to review your (extensive!) code - glad
you got it working!

John W. Vinson[MVP]
 
Back
Top