Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ID required

Status
Not open for further replies.

matrixindicator

IS-IT--Management
Sep 6, 2007
418
BE
For an update of a progress bar required the ID of the main-form with the event current-form. When adding a new record there is not a IDRQ already defined and he said invalid use of null. What can I do about it ? Setting a default ID ? When adding a new record the result of the progress bar should always be 0, nothing, perhaps I can use a dummy value ?

Code:
intForm = [Forms]![F1A_RQ]![IDRQ]
 
If I understand your question look at the NZ function (null to zero)
intForm = NZ([Forms]![F1A_RQ]![IDRQ],0)
 
MajP, great tip, I solved it with this (and a little adaptions of other parts of my code).

I agree, I could explained it a bit better, thanks for understanding.

Code:
Dim intForm As Integer
intForm = Nz([Forms]![F1A_RQ]![IDRQ], 0)

Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
If intForm = 0 Then
    intCountTasks = 0
Else
    intCountTasks = rst!CountTasktitle
End If
 
Why open a recordset when you know you'll don't use it ?
Code:
Dim intForm As Integer
intForm = Nz(Forms!F1A_RQ!IDRQ, 0)
If intForm = 0 Then
    intCountTasks = 0
Else
    Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
    intCountTasks = rst!CountTasktitle
    rst.Close
    Set rst = Nothing
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top