Duplicate a record into several (1 Viewer)

smellyalater

Registered User.
Local time
Today, 14:59
Joined
Mar 21, 2016
Messages
16
Hi Guys

Is there a way to append a record multiple times, if some fields have different values?

EG.

Title | Name | Surname | Q3 | Q2 | Q1
--------------------------------------------------
Mr | Test | Test | Yes | Blank | Maybe

I want to append this record twice but seperate it by the Q3, Q2, or Q1 values?
Title | Name | Surname | Qs|
----------------------------------
Mr | Test | Test | Yes |
Mr | Test | Test | Maybe|

I hope this makes sense, any help would be great!

Thanks
 
if this is in the form you can use this code:

dim i as integer
for i = 1 to 3
if Trim(me.controls("q" & i).Value & "") <> "" then
docmd.runsql "insert into table ([title],[name],[surname],[qs]) select " & _
iif(trim(me.[title] & "")<>"", chr(34) + me.title & chr(34), "null") & "," & _
iif(trim(me.[name] & "")<>"", chr(34) & me.[name] & chr(34), "null") & "," & _
iif(trim(me.[surname] & "")<>"", chr(34) & me.[surname] & chr(34), "null") & "," & _
chr(34) & me.controls("q" & i).value & chr(34) & ";"
end if
next i
 

Users who are viewing this thread

Back
Top Bottom