PDA

View Full Version : Excel form to connect to access database and querying method to work with the data.



nkpan
04-09-2018, 02:47 AM
Hello all,

I am new to use Excel UserForm to connect with access database.

I normally tend to write so many select statements throughout my code, below is the example, this is used many time in my code.

OpenDBnT 'open database connection

sStr = "select * from [People] where Deleted = 'No'"
Set Rs = New ADODB.Recordset
Rs.Open sStr, Con, adOpenStatic, adLockOptimistic ', adLockBatchOptimistic ', adCmdText

CloseDBnt ' close database connection.

Please let me know using select statements so many times in a code is a right way, i feel i am not doing it right way though my code works.

Please guide me if i am going wrong....

Thanks a lot

nkpan