By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,436 Members | 2,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,436 IT Pros & Developers. It's quick & easy.

Overwrite duplicates

P: n/a
Hi everyone,
I am trying to write some VBA code to overwrite duplicates in an
existing table with records that are imported. However I don't want to
overwrite the fields in the exisiting records if the imported file
contains blanks in its fields. Does anyone have any suggestions?
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> I am trying to write some VBA code to overwrite duplicates in an
existing table with records that are imported. However I don't want to
overwrite the fields in the exisiting records if the imported file
contains blanks in its fields. Does anyone have any suggestions?


Are you executing sql in your code or are you opening recordsets and stepping
through the records (or using multiple recordsets and findfirst) to update the
values? If using recordsets, I might use this approach:

'**
'Assuming rs2 is already in .Edit mode
If Len(Trim(rs1!Field1) & "") > 0 Then 'If not null or zero-length strings
rs2!Field1 = rs1!Field1
End If
'**

If executing sql, I don't know that an Update query can be written to do that.

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #2

P: n/a
Thank for your reply. I will give this a go.

'**
'Assuming rs2 is already in .Edit mode
If Len(Trim(rs1!Field1) & "") > 0 Then 'If not null or zero-length strings
rs2!Field1 = rs1!Field1
End If
'**

If executing sql, I don't know that an Update query can be written to do that.

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.