vendredi 18 août 2017

Searching a table where the field doesnt exist - Access VBA

Morning all!

I hope you can help, I am a data consultant who migrates the data I am sent into our system. I have written code that compares what is in my table against what has been put into oracle, as an extra test. The tables are a little convoluted due to how they relate to each other. But essentially here is my question:

When I look to match two field values and the field doesnt exist I get a parameter pop up box. I want to only run the code if the field exists.

I have tried many things, wrapping an if statement around it but I always get the parameter box, can anyone help there must be an easier way to do this!

If Not DoCmd.OpenQuery("SELECT TOP 1" & MatchValues!FieldName & " FROM " & 
MatchValues!ORACLE_TABLE_NAME) Then

  MsgBox "moomins"
'    strSQL = "INSERT INTO 002_TableValueErrors(ORACLE_TABLE_NAME,TRANSFORM_TABLE_NAME,FIELD_NAME,ORACLE_FIELD_VALUE,TRANSFORM_FIELD_VALUE) "
 '   strSQL = strSQL & " VALUES (" & MatchValues!ORACLE_TABLE_NAME & "," & MatchValues!TRANSFORM_TABLE_NAME & "," & MatchValues!FieldName & ",'ORACLE: NOT FOUND','ORACLE: NOT FOUND')"

End If

Aucun commentaire:

Enregistrer un commentaire