Continuous form advice

Indigo

Registered User.
Local time
Today, 11:52
Joined
Nov 12, 2008
Messages
241
I am running Access 2003 and need some advice regarding a continuous subform. The main form is unbound and the continuous subform is bound to a temporary table. When the user clicks the "submit" button, the code writes the data to a "permanent" table. There are times, however, when there will be no data on the subform, so as a work around, I am using an If IsNull....Then statement:

Code:
    If IsNull(Forms![frmProblemInvestigation]!subfrmPITempCM.Form!TempCM.Value) Then
        'Do Nothing
        Else
        HoldPITempRS.MoveFirst
        Do While Not HoldPITempRS.EOF
            PITempRS.AddNew
            PITempRS.Fields("ProblemInvestigationID").Value = HoldProblemInvestigationID
            PITempRS.Fields("TempCM").Value = HoldPITempRS!TempCM
            PITempRS.Fields("Responsible").Value = HoldPITempRS!Responsible
            PITempRS.Fields("TargetDate").Value = HoldPITempRS!TargetDate
            PITempRS.Fields("ActualDate").Value = HoldPITempRS!ActualDate
            PITempRS.Update
        HoldPITempRS.MoveNext
        Loop
        End If
        PITempRS.Close

However, and I suppose this is due to the nature of subforms, the code sometimes "skips" when the value in the TempCM field is NOT null. Does anyone have any advice and or a work around to this issue? Thank you.
 
:confused:

I tried to set focus to the TempCM field but that didn't help.

I took away the If.. Then....Else statement

and I got a "No Current Record" error if I left the TempCM blank.

Help, please....just point me in the right direction.....
 
I don't think I'd bother with the form, as the EOF loop of the recordset should be enough (I'm assuming that recordset is based on the table). You would want to get rid of this line:

HoldPITempRS.MoveFirst

In my experience the recordset will always start on the first record, and that line will error if there are no records.
 

Users who are viewing this thread

Back
Top Bottom