VBA Code to ensure data just sent to Access from Excel are not duplicates

mxtreme

New Member
Joined
Jun 28, 2010
Messages
9
The previous developer basically took the metrics from the last row in Excel and used SQL to identify what should be
- date
- metric ref #
- value
in the Access table
Is there something I can do where I can grab that newly created record created by using SQL and then say
Code:
Dim ExcelRecord as String
Dim AccessRecord as String



If ExcelRecord = NEWLY CREATED Access Record from using sql Then
   bfound = True
Else
  bfound = False
End If


MSQL = _
Code:
" SELECT Metrics.Metric, Reporting_H.Level_1,  Metrics_X_Reporting_H.Metric_ID, Info_Weekly.Date, " _
    & "Info_Weekly.Value " & _
    "FROM ((Metrics_X_Reporting_H INNER JOIN Metrics ON  Metrics_X_Reporting_H.Metric_Name_ID = Metrics.Metric_Name_ID) " _
    & _
    "INNER JOIN Reporting_H ON Metrics_X_Reporting_H.H_ID =  Reporting_H.H_ID) " _
    & _
    "INNER JOIN Info_Weekly ON Metrics_X_Reporting_H.Metric_ID =  Info_weekly.Metric_ID " _
    & "WHERE (((Metrics.Metric)='" & "Force Completed On Time -  Weekly" & "') " & _
    "AND ((Reporting_H.Level_1)='" & "ELT" & "') " & _
    "AND ((Info_weekly.Date)='" & MDate & "'));"
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Not sure exactly what you are doing.

One way of checking is to do an Excel Find for something in the retrieved record to see if it already exists.
 
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,859
Members
449,472
Latest member
ebc9

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