Message box question

  • Thread starter Thread starter hotplate
  • Start date Start date
H

hotplate

Is there a way that I can display a message using msgbox that after a
field is populated, the records are searched for the same entry and
give a count.

Something like:

msgbox "There are " (insert count here) "records that have the same
information."

Thanks
James
 
in message
Is there a way that I can display a message using msgbox that after a
field is populated, the records are searched for the same entry and
give a count.

Something like:

msgbox "There are " (insert count here) "records that have the same
information."

Thanks
James


You'd probably use the control's AfterUpdate event, and use DCount to find
out how many matching records there are. Something like:

'------ start of example code ------
Private Sub YourControlName_AfterUpdate()

Dim lngCount As Long

lngCount = _
DCount("*", "YourTableName", _
"YourFieldName=[Forms]![YourFormName]![YourControlName]")

MsgBox _
"There are " & lngCount & "records that have the same information."

End Sub
'------ end of example code ------
 
Back
Top