Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Result of Query in Message Box

Status
Not open for further replies.

njvsummit

MIS
Apr 5, 2004
20
US
This should be simple, but I can't seem to figure it out. I have a command button that kicks off some steps to import a text file. After the file is imported, I then want to query the table to get a count of the number of records in the table and display that count in a message box to the user. How would I go about displaying the result of that query in the message box?

Thanks

Nick
 
Hi

Unless I'm mis-reading your problem, it should be very easy.

If you are accessing a table, you just need to query the tables' recordcount before and after the import.
Code:
Dim rs As Recordset

Set rs = CurrentDb.OpenRecordset("Table1")

MsgBox "There are " & rs.RecordCount & " records in this table BEFORE import"

<code to import etc>
' the table will now have extra records

MsgBox "There are " & rs.RecordCount & " records in this table AFTER import"

rs.Close
Set rs = Nothing

Hope this helps
 
As Ormsk said,

or as another option...

..import table code...

Dim iRecordCount As integer
iRecordCount = DCount("pkID", "tblTable1")

MsgBox "You have succesfully appended " & vbCrLf & iRecordCount & " Records, to Table1"

Good Luck!
 
Thanks for the info--I know very little about vb and recordsets. If I wanted to go a step further and lets say one of the fields in the newly imported table is a date and I wanted to get the Min and Max of that field to add the statement the table contains services ranging from "X" through "Y" --what would be the syntax for that?

Thanks again for the help!
 
how about...

strMinDate = DMin("DateField", "tblTable1")
strMaxDate = DMax("DateField", "tblTable1")


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top