C
Chris
I have a continuous form for the user to review and delete records;
ultimately all the records will be deleted. Then I want to close the form. I
use HasData and get an error "you entered an expression that has no value."
Well, all the records are gone, but how do I get around this? Works great
when there are records.
My code:
Private Sub btnCloseForm_Click()
If HasData1(CRRefInvNum) Then
MsgBox "something still there."
Exit Sub
End If
DoCmd.Close
End Sub
Function HasData1(CRRefInvNum) As Boolean
'This routine tests for record and suppresses form if no data.
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim SQL As String
Set db = CurrentDb()
SQL = "SELECT [tbl 1 ClientCreditApplied].CRRefInvNum FROM [tbl 1
ClientCreditApplied] WHERE [CRRefInvNum] =" & [CRRefInvNum] & ";"
Set rst = db.OpenRecordset(SQL)
If rst.EOF And rst.BOF Then
HasData1 = False
Else
HasData1 = True
End If
End Function
I know its because [CRRefInvNum]s are all gone, but what can I do to just
close the form?
ultimately all the records will be deleted. Then I want to close the form. I
use HasData and get an error "you entered an expression that has no value."
Well, all the records are gone, but how do I get around this? Works great
when there are records.
My code:
Private Sub btnCloseForm_Click()
If HasData1(CRRefInvNum) Then
MsgBox "something still there."
Exit Sub
End If
DoCmd.Close
End Sub
Function HasData1(CRRefInvNum) As Boolean
'This routine tests for record and suppresses form if no data.
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim SQL As String
Set db = CurrentDb()
SQL = "SELECT [tbl 1 ClientCreditApplied].CRRefInvNum FROM [tbl 1
ClientCreditApplied] WHERE [CRRefInvNum] =" & [CRRefInvNum] & ";"
Set rst = db.OpenRecordset(SQL)
If rst.EOF And rst.BOF Then
HasData1 = False
Else
HasData1 = True
End If
End Function
I know its because [CRRefInvNum]s are all gone, but what can I do to just
close the form?