Form just won't open

April15Hater

Accountant
Local time
Today, 15:02
Joined
Sep 12, 2008
Messages
349
Hey guys-

I have another problem coming up, and it's pretty weird. Simply put, I can't open a form I just made. I dblclk it and it just sits there like nothing happened. I've tried both form and design view and it doess the same thing. I tried to open it with docmd.openform from the immediate window but it gives me the error- "Run-time error '2001': You canceled the previous operation."

I've built this form twice now, and it started giving me problems when I tried to open it with the following command:
docmd.OpenForm "frmProductionEdit", , , , , , 3903

Thanks,

Joe
 
some corruption issue

can you open the forms underlying query? type mismatch error maybe? that will stop the form opening
 
only thing I can see is the underlying VB code I have for it. What is frustrating is that I know when it's being corrupted, and I don't know how to make it not happen. I also tried to open w/ quotes around the openarg....would it stop design view also?
 
Being unable to open in Form view or Design View pretty much means corruption, as Dave has said. You might try creating a new, blank database, importing everything except the errant form, then recreating the form.

I'd leave off the code handling the OpenArgs at first and see if the form will then open.
 
Last edited:
It's really just populating text boxes. Just for the heck of it, I tried to delete the open form code and it causes Access to error out.

Code:
Private Sub Form_Load()
Dim rsProduction As ADODB.Recordset
Dim rsSubFunction As ADODB.Recordset
Dim rsFormSetup As ADODB.Recordset
Dim rsAppendTracking As ADODB.Recordset
If IsNull(Me.OpenArgs) = True Then MsgBox "Error! No ProductionID assigned.", vbCritical: DoCmd.Close acForm, "frmProductionStep4b": Exit Sub
Set rsProduction = New ADODB.Recordset
Set rsSubFunction = New ADODB.Recordset
Set rsFormSetup = New ADODB.Recordset
Set rsAppendTracking = New ADODB.Recordset
'Set ProductionID
With txtProductionID
    .Value = Me.OpenArgs
    .Enabled = False
End With
With txtFunctionTrack
    .Enabled = False
End With
With rsFormSetup
    .ActiveConnection = CurrentProject.Connection
    .Source = "SELECT tblFunction.FunctionID, tblFunction.JobID, tblProductionInput.ProductionID, tblFunction.[Function Name], " _
            & "tblProductionTracking.TrackingNumber, tblProductionInput.Status, tblFunctionTracking.FunctionTrackingID, " _
            & "tblFunctionTracking.Hierarchy, tblFunctionTracking.TrackableItem, tblProductionInput.InitiationDate, " _
            & "tblProductionInput.CompleteDate, tblProductionInput.QCCompleteDate " _
            & "FROM (tblFunction INNER JOIN (tblProductionInput INNER JOIN tblProductionTracking ON " _
            & "tblProductionInput.ProductionID = tblProductionTracking.ProductionID) ON " _
            & "tblFunction.FunctionID = tblProductionInput.FunctionID) INNER JOIN tblFunctionTracking ON" _
            & "(tblFunctionTracking.FunctionTrackingID = tblProductionTracking.FunctionTrackingID) AND" _
            & "(tblFunction.FunctionID = tblFunctionTracking.FunctionID) " _
            & "WHERE tblProductionInput.ProductionID = " & Me.OpenArgs & " AND IsNull(tblFunctionTracking.Hierarchy) = False;"
    .CursorType = adOpenDynamic
    .LockType = adLockReadOnly
    .Open
    'Disable FunctionID Dependent Text Boxes that have no record in tblContractorFunction
    Call ClearFunctionDependent(CStr(!FunctionID))
    'Populate various items on the form
    txtInitiationDate = !InitiationDate
    txtCompleteDate = !CompleteDate
    txtQCCompleteDate = !QCCompleteDate
    txtEditDate = !EditDate
    txtFinalizeDate = !FinalizeDate
    txtClosingDate = !ClosingDate
    txtProductionID = !ProductionID
    txtFunctionTrack = !TrackingNumber
    lblFunctionTrack.Caption = FindFunctionTrack(CStr(rsFormSetup!FunctionID), 2)
    cboClientJob.Value = !JobID
    cboFunction.Value = !FunctionID
    fmeStatus = !Status
    With rsProduction
        .ActiveConnection = CurrentProject.Connection
        .Source = "TRANSFORM Sum(tblProductionInputDetail.ProductionUnits) AS SumOfProductionUnits " _
                & "SELECT tblProductionInputDetail.ProductionID " _
                & "FROM tblContractorFunction INNER JOIN tblProductionInputDetail ON " _
                & "tblContractorFunction.ContractorFunctionID = tblProductionInputDetail.ContractorFunctionID " _
                & "WHERE (tblContractorFunction.FunctionType = " & Chr(34) & "Aerial" & Chr(34) & " OR " _
                & "tblContractorFunction.FunctionType = " & Chr(34) & "Underground" & Chr(34) & " OR " _
                & "tblContractorFunction.FunctionType = " & Chr(34) & "Unit" & Chr(34) & " OR " _
                & "tblContractorFunction.FunctionType = " & Chr(34) & "setup" & Chr(34) & ") And " _
                & "tblProductionInputDetail.ProductionID = " & Me.OpenArgs & " " _
                & "GROUP BY tblProductionInputDetail.ProductionID " _
                & "PIVOT tblContractorFunction.FunctionType;"
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        .Open
        'Populate Aerial Footage Textbox
        If ProductionDetailExists(ContractorFunctionIDLookup(rsFormSetup!FunctionID, "Aerial"), Me.OpenArgs) Then
            With txtAerial
                .Value = rsProduction!Aerial
                .Enabled = True
            End With
        End If
        'Populate Underground Footage TextBox
        If ProductionDetailExists(ContractorFunctionIDLookup(rsFormSetup!FunctionID, "Underground"), Me.OpenArgs) Then
            With txtUnderground
                .Value = rsProduction!Underground
                .Enabled = True
            End With
        End If
        'Populate Unit Footage TextBox
        If ProductionDetailExists(ContractorFunctionIDLookup(rsFormSetup!FunctionID, "Unit"), Me.OpenArgs) Then
            With txtUnit
                .Value = rsProduction!Unit
                .Enabled = True
            End With
        End If
        'Populate Setup Check box
        If ContractorFunctionIDLookup(rsFormSetup!FunctionID, "Setup") <> "" Then
            With chkSetup
                .Enabled = True
                If ProductionDetailExists(ContractorFunctionIDLookup(rsFormSetup!FunctionID, "Setup"), Me.OpenArgs) Then
                    .Value = rsProduction!Setup
                End If
            End With
        End If
        .Close
    End With
    ActivateSubFunctions (!FunctionID)
End With

'Populate SubfunctionData
With rsSubFunction
    .ActiveConnection = CurrentProject.Connection
    .Source = "SELECT qtrProduction.ProductionID, qtrProduction.FunctionType, qtrProduction.ProductionUnits, " _
            & "qtrProduction.InitiationDate, qtrProduction.CompleteDate, qtrProduction.QCCompleteDate, qtrProduction.FinalizeDate " _
            & "FROM qtrProduction " _
            & "WHERE ProductionID = " & Me.OpenArgs & " AND " _
                & "FunctionType <> " & Chr(34) & "Aerial" & Chr(34) & " AND " _
                & "FunctionType <> " & Chr(34) & "Underground" & Chr(34) & " AND " _
                & "FunctionType <> " & Chr(34) & "Unit" & Chr(34) & " AND " _
                & "FunctionType <> " & Chr(34) & "Setup" & Chr(34)
    .CursorType = adOpenDynamic
    .LockType = adLockOptimistic
    .Open
    If Not .EOF Then
        Do
            If !FunctionType = "House Count" Then
                With Me.txtHouseCount
                    .Enabled = True
                    .Value = rsSubFunction!ProductionUnits
                End With
            End If
            If !FunctionType = "Commercial Count" Then
                With Me.txtCommercialCount
                    .Enabled = True
                    .Value = rsSubFunction!ProductionUnits
                End With
            End If
            If !FunctionType = "MDU Count" Then
                With Me.txtMDUCount
                    .Enabled = True
                    .Value = rsSubFunction!ProductionUnits
                End With
            End If
            .MoveNext
        Loop Until .EOF
        .MoveFirst
    End If
    For IntX = 1 To 13
        If Not .EOF Then
            If !FunctionType <> "House Count" And !FunctionType <> "Commercial Count" And !FunctionType <> "MDU Count" Then
                Me.Controls("lblSubFunction" + Format$(IntX)).Caption = !FunctionType
                Me.Controls("txtSubFunction" + Format$(IntX)).Value = !ProductionUnits
                .MoveNext
            Else
                With Me.Controls("lblSubFunction" + Format$(IntX))
                    .Visible = False
                    .Caption = "SubfunctionType" & IntX
                End With
                With Me.Controls("txtSubFunction" + Format$(IntX))
                    .Enabled = False
                    .Visible = False
                    .Value = Null
                End With
            End If
        End If
    Next IntX
End With
Me.cboFunctionTrack.Requery
End Sub
 

Users who are viewing this thread

Back
Top Bottom