form unload if.........

kabir_hussein

Registered User.
Local time
Today, 11:10
Joined
Oct 17, 2003
Messages
191
Hi

i have a form where if there is no data i can not exit the form as it is testing some other textboxes for error.

I wanted to aks if anyone knew of a way of making a form not open up if it has no data.

Many thanks in advance

kabir
 
Check the recordset assigned to the form before you open it:

Code:
If DCount("MyField", "MyTable", "MyOtherField = " & varMyCriteria) = 0 Then
    MsgBox "There is nothing to show.", vbInformation
    Exit Sub
Else
    DoCmd.OpenForm etc, etc, etc.
End If
 
Hi many thanks for the advice but what do you mean by recordset. i dont understand how this effect it.

also regarding the code what do i type in for the VarMyCriteria.

If DCount("MyField", "MyTable", "MyOtherField = " & varMyCriteria) = 0 Then
MsgBox "There is nothing to show.", vbInformation
Exit Sub
Else
DoCmd.OpenForm etc, etc, etc.
End If

below is what i have changed:

If DCount("BuyersName", "purchase", "PurchaseOrderID = " & varMyCriteria) = 0 Then
MsgBox "There is nothing to show.", vbInformation
Exit Sub
Else
Dim invoice As String
invoice = "invoicefrm"
DoCmd.OpenForm invoice
End If
End Sub

thank for help
 
kabir_hussein said:
what do you mean by recordset.

Basically, the form's RecordSource - be it a table or a query (preferable).

what do i type in for the VarMyCriteria.

A control or variable that holds the PurchaseOrderID value you want.
 
thank you very much Mile-O-Phile


i have managed to get it to work

very greatful
 

Users who are viewing this thread

Back
Top Bottom