Message box question

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
 
D

Dirk Goldgar

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 ------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top