Afternoon,
So im looking for a bit of help.
i want to retrieve some data from a table i have pieced together a bit of code but get an error to few parameters.
any help or pointing to the right direction would be appreciated.Code:Dim db As dao.Database Dim Lrs As dao.Recordset Dim LSQL As String Dim Lname As String 'Open connection to current Access database Set db = CurrentDb() 'Create SQL statement to retrieve value from contacts table LSQL = "SELECT Contacts.Cn " & _ "FROM Contacts " & _ "WHERE (((Contacts.Cc)=[Forms]![frmClaims]![frmClaims_ThirdParty]![thirdPartyCc]))" Debug.Print LSQL Set Lrs = db.OpenRecordset(LSQL) 'Retrieve value if data is found If Lrs.EOF = False Then Lname = Lrs("cn") Else Lname = "Not found" End If Lrs.Close Set Lrs = Nothing getgst = Lname Debug.Print getgst
when i paste the SQL into a query it works fine