Hi
I have the following code which works perfectly to display a message box when a query returns no results
Code:
Private Sub btn_Search_Click()
TempVars.Add "varYearOfBanns", Me.txtYearOfBanns.Value
If DCount("*", "qry_BannsYearOfSearch") > 0 Then
DoCmd.Close acForm, "frm_BannsYearSearch"
DoCmd.OpenForm "frm_BannsYearOfBannsSearchResults", acNormal, "", "", , acNormal
Else:
MsgBox "There are no Banns Records for this Year"
End If
End Sub
I wanted to remove the tempVar if there were no results so I modified the VBA to be:
Code:
Private Sub btn_Search_Click()
TempVars.Add "varYearOfBanns", Me.txtYearOfBanns.Value
If DCount("*", "qry_BannsYearOfSearch") > 0 Then
DoCmd.Close acForm, "frm_BannsYearSearch"
DoCmd.OpenForm "frm_BannsYearOfBannsSearchResults", acNormal, "", "", , acNormal
Else:
tempvars.remove "varYearOfBanns"
MsgBox "There are no Banns Records for this Year"
End If
End Sub
Is this code correct to remove the temp var because when I use it the database hangs
thanks
Ian