C
ckendricks7
This is my second time posting this problem:
have a form that pulls up individual client records utilizing a
parameter query as it's Record Source. I want to open a MsgBox if more
than one client record is returned. I know that I can use the DCount
function and a field from the returned data (like the primary key) to
somehow trigger a MsgBox, but I just can't seem to get it to work.
Maybe I should note that the primary form contains a subform with four
tab controls.
It was suggested that I try the following procedure in response to the
Form_Load event:
Private Sub Form_Load()
If Me.Recordset.RecordCount > 1 Then
MsgBox Me.Recordset.RecordCount _
& " records were returned" _
, , "RecordCount"
Else
MsgBox "one record was returned" _
, , "One record"
End If
End Sub
When I tried this procedure the MsgBox "one record was returned" comes
up every time. Even if I enter a phone number (which I use as the
criteria for the client search), for which I know there are multiple
records (husband and wife clients). However I noticed that if after I
give it a phone number for which I know there are multiple records, and
it responds with the "one record was returned" MsgBox, if I immediately
go to Design mode, and then back to Form mode, THEN the correct MsbBox
is displayed ("2 records were returned"). I have tried tying the code
to several different form events, with the same results
What am I doing wrong???
have a form that pulls up individual client records utilizing a
parameter query as it's Record Source. I want to open a MsgBox if more
than one client record is returned. I know that I can use the DCount
function and a field from the returned data (like the primary key) to
somehow trigger a MsgBox, but I just can't seem to get it to work.
Maybe I should note that the primary form contains a subform with four
tab controls.
It was suggested that I try the following procedure in response to the
Form_Load event:
Private Sub Form_Load()
If Me.Recordset.RecordCount > 1 Then
MsgBox Me.Recordset.RecordCount _
& " records were returned" _
, , "RecordCount"
Else
MsgBox "one record was returned" _
, , "One record"
End If
End Sub
When I tried this procedure the MsgBox "one record was returned" comes
up every time. Even if I enter a phone number (which I use as the
criteria for the client search), for which I know there are multiple
records (husband and wife clients). However I noticed that if after I
give it a phone number for which I know there are multiple records, and
it responds with the "one record was returned" MsgBox, if I immediately
go to Design mode, and then back to Form mode, THEN the correct MsbBox
is displayed ("2 records were returned"). I have tried tying the code
to several different form events, with the same results
What am I doing wrong???