S
S Jackson
I am trying to build in a message box that displays the number of records a
user finds when he executes a Search from my fdlgSearch form. Here is the
code so far:
Dim stDocName As String
Dim stLinkCriteria As String
Dim rst As Recordset
stDocName = "frmMaster"
stLinkCriteria = "[CaseName]Like" & "'" & Me![txtSearch] & "*" & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Set rst = CurrentDb.OpenRecordset(stLinkCriteria)
If rst.RecordCount = 0 Then
MsgBox "The database did not fine any records, please try again."
DoCmd.Close
Else
rst.MoveLast
MsgBox "The database found " _
& rst.RecordCount _
& " case(s).", vbInformation, "Record Count"
End If
I get a message when the "frmMaster" opens that reads:
The Microsoft Jet database engine cannot find the input table or query
'[CaseName]Like'new*". Make sure it exists that that its name is spelled
correctly.
Any suggestions are greatly appreciated. Thanks.
P.S. I know I can put simple code in the "frmMaster" that counts the number
of records that the it finds, but I use this form for other purposes and I
do not want a Message Box displaying the number of records it find every
time a user opens this form. The other alternative is to create another
form, but I am trying to reduce the size of my database objects as it seems
that I have so many of them now.
Which makes the database run more efficiently:
a. create a second form and put in code to count the records in the
"OnOpen" Event; or
b. stay with a single form and attempt to make the code work above.
Thanks.
S. Jackson
user finds when he executes a Search from my fdlgSearch form. Here is the
code so far:
Dim stDocName As String
Dim stLinkCriteria As String
Dim rst As Recordset
stDocName = "frmMaster"
stLinkCriteria = "[CaseName]Like" & "'" & Me![txtSearch] & "*" & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Set rst = CurrentDb.OpenRecordset(stLinkCriteria)
If rst.RecordCount = 0 Then
MsgBox "The database did not fine any records, please try again."
DoCmd.Close
Else
rst.MoveLast
MsgBox "The database found " _
& rst.RecordCount _
& " case(s).", vbInformation, "Record Count"
End If
I get a message when the "frmMaster" opens that reads:
The Microsoft Jet database engine cannot find the input table or query
'[CaseName]Like'new*". Make sure it exists that that its name is spelled
correctly.
Any suggestions are greatly appreciated. Thanks.
P.S. I know I can put simple code in the "frmMaster" that counts the number
of records that the it finds, but I use this form for other purposes and I
do not want a Message Box displaying the number of records it find every
time a user opens this form. The other alternative is to create another
form, but I am trying to reduce the size of my database objects as it seems
that I have so many of them now.
Which makes the database run more efficiently:
a. create a second form and put in code to count the records in the
"OnOpen" Event; or
b. stay with a single form and attempt to make the code work above.
Thanks.
S. Jackson