SQUIDD
Well-known Member
- Joined
- Jan 2, 2009
- Messages
- 2,126
- Office Version
- 2019
- 2016
- Platform
- Windows
Good morning
So I am using excel to add data to access database using forms. Got this working just great.
But, i need to be able to bring data back from access into my excel forms so i can modify and update.
The code below brings back data into a sheet for now, but its not the data i need, it seems its only the smallest id.
I just dont know how to write the code so it can search for a specific record.
I want to search a column called PO NUMBER in the access file. have added an input box for testing to search the record.
Sorry if this is obvious but i am extremly new to using access.
thanks in advance
dave
So I am using excel to add data to access database using forms. Got this working just great.
But, i need to be able to bring data back from access into my excel forms so i can modify and update.
The code below brings back data into a sheet for now, but its not the data i need, it seems its only the smallest id.
I just dont know how to write the code so it can search for a specific record.
I want to search a column called PO NUMBER in the access file. have added an input box for testing to search the record.
Sorry if this is obvious but i am extremly new to using access.
thanks in advance
dave
VBA Code:
Sub today()
Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & "Data Source=D:\DATA\data.accdb;"
Set rs = New ADODB.Recordset
rs.Open "MASTER", cn, adOpenKeyset, adLockOptimistic, adCmdTable
PO = InputBox("ENTER RECORD TO FIND")
Range("a1") = rs.Fields(1).Value
Range("a2") = rs.Fields(2).Value
Range("a3") = rs.Fields(3).Value
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub