Can you please help with access database queries from excel vba
My algorithm is as follows:
Open connection to access database
Select table1.column1, table1.column2, table1.column3 where table1.column3.value = “x” and table1.column2.value = “y”
Switch Case 1: If no records found matching the criteria from access database
Insert some values etc…
Switch Case 2 : If records found matching the criteria from access database
No action needed
Switch Case 3 : If records found not matching the criteria values from access database
Should display the values in an datagridview in excel vba
Should not allow to insert values
Kindly help me with the code needed from excel vba
Thanks Prabu M
note that the case3
an case1
are similar
you can use this code
Dim recSet As Recordset
Set recSet = CurrentDb.OpenRecordset("Select table1.column1, table1.column2,"_
& "table1.column3 where table1.column3.value = 'x' and table1.column2.value = 'y'")
If recSet.EOF Then 'No records matching criteria
'Do something
Else 'There was records found
'Do Something else
End If
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.