"New" <
amanda77777@gmail.com>wrote in message
Quote
I am using Acess 2003 Code Builder.
Can I do the following? Why is the syntax wrong?
(txtDistrictCode.Text)="") <-- extra paren and you have an 'Or And' in
there too... also, it's hard to tell if 'CountyName' is a box or a variable.
'here's another way...
If (txtDistrictName.Text = "") _
Or (txtSchoolName.Text = "") _
Or (CountyName.Text = "") _
Or (txtDistrictCode.Text = "") _
Or (txtSchoolCode.Text = "") _
Or (txtRegionNumber.Text = "") _
Or (cboProgramName.Text = "") _
Or (cboFiscalYear.Text = "") Then
MsgBox "Please enter at least one search criteria to see records.",
vbOKOnly, "Error"
txtDistrictName.SetFocus
End If
Here's the "long hand" way... using copy/paste, it's not much more typing
but it's far easier to read (imo) plus, using Len is faster than comparing
strings.
'==========
Private Sub Command1_Click()
Dim bEmptyBox As Boolean
If Len(txtDistrictName.Text) = 0 Then
bEmptyBox = True
End If
If Len(txtSchoolName.Text) = 0 Then
bEmptyBox = True
End If
If Len(CountyName.Text) = 0 Then
bEmptyBox = True
End If
If Len(txtDistrictCode.Text) = 0 Then
bEmptyBox = True
End If
If Len(txtSchoolCode.Text) = 0 Then
bEmptyBox = True
End If
If Len(txtRegionNumber.Text) = 0 Then
bEmptyBox = True
End If
If Len(cboProgramName.Text) = 0 Then
bEmptyBox = True
End If
If bEmptyBox Then
MsgBox "Please enter at least one search criteria to see records.",
vbOKOnly, "Error"
txtDistrictName.SetFocus
End If
End Sub
'==========
--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard -
www.vbsight.com/ComGuard.htm">
www.vbsight.com/ComGuard.htm
In Loving Memory -
www.vbsight.com/Remembrance.htm">
www.vbsight.com/Remembrance.htm
-