Find or Extract data from database

mohan.r1980

New Member
Joined
Oct 27, 2010
Messages
43
Hello Friends,
i have excel data and i have created a table in database file and add the data.
below code make the database file

Code:
Option Explicit
Sub DAOFromExcelToAccess()
' Please Select first "Microsoft DAO 3.6 Object Library fron Tool>>Reference
' exports data from the active worksheet to a table in an Access database
' this procedure must be edited before use

Dim iSh As Worksheet
Dim db As Database, rs As Recordset
Dim i As Long
    Set iSh = ThisWorkbook.Sheets("Sheet1")
   ' Set db = OpenDatabase("D:\Temp\Export To Access\My Data.accdb")
    Set db = OpenDatabase("D:\Temp\Export To Access\My Data.mdb")
    ' open the database

    Set rs = db.OpenRecordset("PENDINGTABLE", dbOpenTable)
    
    For i = 1 To WorksheetFunction.CountA(ActiveSheet.Range("A1").EntireColumn) - 1
        With rs
            .AddNew ' create a new record
            ' add values to each field in the record
            .Fields("SRNO") = iSh.Range("A" & i + 1).Value
            .Fields("BCM_CLIENT_ID") = Range("B" & i + 1).Value
            .Fields("STATUS_NAME") = Range("C" & i + 1).Value
            .Fields("FIRST_HOLDER_NAME") = Range("D" & i + 1).Value
            .Fields("PIN_CODE") = Range("E" & i + 1).Value
            
            ' add more fields if necessary...
            .Update ' stores the new record
            
        End With
    Next i
    
    
    rs.Close
    Set rs = Nothing
    db.Close
    Set db = Nothing
End Sub


Now i want to extract this data from database to excel.

i also want to do if i put SrNo in Input box then msgbox will pop up with Client Name.

Please suggest me
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,213,510
Messages
6,114,037
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top