Cant follow this code

accessma

Registered User.
Local time
Today, 00:05
Joined
Sep 17, 2006
Messages
54
I have a form and a two subforms within it. The subforms are the problem. I'm having a problem finding out why the field in the Reports table gets set to zero when a new Status report is added. The sub forms in question are called frmStatusReport and frmProject_sbfrmProjectStatus. The main form is frmProject.

The ideas is this:

When you open frmProject you see the sub forms frmStatusReport and frmProject_sbfrmProjectStatus.

There are three buttons to choose from. If you add a Status Report the report number gets set to zero. The Edit and Delete routines in the Edit and Delete buttons look for the ReportNo field in the Report table to be <> 0 which of course it is not. So you cannot edit or delete and reports that you enter.

Can anyone tell me what is hasppening and where the error in the code is? Im attaching sample FE and BE DB's.
 

Attachments

Without downloading 2 files, unzipping them and (I assume having to reset the path between the two dbs) I'm going to guess that Report Number is, in fact a number. When you create a number field in table Design View, the default for the DefaultValue is zero. If this is so, go into the table and delete this value.
 
That resulted in the following run time error:

Invalid use of null

on the code below with the bolded line:

Code:
Private Sub cmdEdit_Click()
    '
    Dim lngReportNo As Long, lngProjID As Long
    '
   [B] lngReportNo = Me.frmProject_sbfrmProjectStatus.Form.ReportNo[/B]
    lngProjID = Me.frmProject_sbfrmProjectStatus.Form.ProjID
    If Len("" & lngReportNo) <> 0 And lngReportNo <> 0 Then
        '
        DoCmd.OpenForm "frmStatusReport", acNormal, , "[projid] = " & lngProjID & " AND [reportno] = " & lngReportNo, acFormEdit, acWindowNormal, "EDIT|" & lngProjID & "|" & lngReportNo
        '
    Else
        '
        MsgBox "Please select a Status Report first.", vbOKOnly + vbInformation, "PID Work Grid"
        '
    End If
    '
End Sub
 

Users who are viewing this thread

Back
Top Bottom